log/fluent_client prints errors when log lines are too long
The following error can be seen when the fluentd client attempts to write a message that is too big: write: message too long or short write and can be attributed to this line of code.
Specifically, this has been observed when eventpb.QueryExecute events are logged with large placeholder values, resulting in conn.Write in fluent_client.go to error. To fix, I see two potential options:
- Add some truncation logic to truncate the data in these events if they are too big
- Break the fluent sink writes up into small chunks to avoid message too long errors.
Jira issue: CRDB-44655
Hi @kyle-a-wong , we were the ones that opened the support ticket - both options are fine for us.
Hi @harelsafra, we recommend using TCP. Was there a reason you chose UDP over default TCP?
Hi @kevin-v-ngo, the choice to use UDP was done on purpose to avoid blocking the CRDB process in case the fluentd process we're sending to is down or having issues. This log streams all SQL executions so we can afford to lose some of them in these cases
@harelsafra
CRDB's processing remains unaffected even if log sinks are unavailable.
- Network logging to fluent or any other sink (eg. HTTP, File, or OTLP) are asynchronous and buffered by default. If Fluent Bit or the network path is unavailable, CRDB enqueues logs in memory and a background goroutine retries delivery. When the buffer reaches capacity, older logs are evicted. This process is non-blocking and does not impact request handling.
- CRDB does not wait for acknowledgments from downstream systems (eg. Grafana or Loki). As long as Fluent Bit is reachable and accepting TCP connections, logs are considered "sent". If failures occur downstream from Fluent Bit, they must be debugged at that level—CRDB remains unaffected.
- Log writing is decoupled from CRDB’s main execution flow. A dedicated background flusher, running in separate goroutines, handles log transmission and manages reconnections when necessary.
- Log emission does not apply backpressure to the system. In the worst case, logs may be dropped, but application throughput remains unaffected.
Thanks for the explanation @Abhinav1299