Closed Priya997 closed 10 months ago
@Priya997 thanks for the issue report! Let's see if we can figure out how to reproduce it reliably.
I think this is happening because no individual span attribute string is larger than the maximum size of the string table, but the combined size of all attributes is. That's a tricky case to handle, because we need to provide clear feedback to the user about what's causing the overflow. In this case there isn't one particular string that's causing the overflow - instead it's the combined size of all of them.
What details can you share about the application in which you're seeing this error?
Have you considered adjusting the DD_TRACE_WRITER_BUFFER_SIZE_BYTES
environment variable to make the buffer large enough to contain all of the span attributes?
@emmettbutler Yes, after increasing the DD_TRACE_WRITER_BUFFER_SIZE_BYTES
to 10MB. It's not failing in our case anymore.
What details can you share about the application in which you're seeing this error?
On this, we are tracking the trace of celery queues, which is resulting in this error. After a task is executed successfully we call this method trace_after_publish
after executing the task successfully.
Thanks @Priya997. I think that since increasing the buffer size worked for you, we can close this issue. Do you agree?
@emmettbutler We started facing this again. Can we look for a long-term fix? Increasing the buffer size every time doesn't sound feasible.
@emmettbutler Can you please check this?
@Priya997 sure, no problem. What failure mode are you experiencing now? Do you have a traceback you can share?
Piggybacking here as I'm not sure if my issue is a different one.
ValueError: Cannot insert https://graph.facebook.com/v17.0/<id>/users?access_<redacted>&appsecret_proof=<redacted>&payload=<redacted url encoded str 699 chars long>...
File "ddtrace/internal/_encoding.pyx", line 481, in ddtrace.internal._encoding.MsgpackEncoderBase._pack_trace
File "ddtrace/internal/_encoding.pyx", line 803, in ddtrace.internal._encoding.MsgpackEncoderV05.pack_span
File "ddtrace/internal/_encoding.pyx", line 743, in ddtrace.internal._encoding.MsgpackEncoderV05._pack_string
File "ddtrace/internal/_encoding.pyx", line 186, in ddtrace.internal._encoding.StringTable._index
File "ddtrace/internal/_encoding.pyx", line 255, in ddtrace.internal._encoding.MsgpackStringTable.insert
RuntimeError: failed to pack span: <Span(id=<id>,trace_id=<id>,parent_id=<id>,name=requests.request)>. Exception: Cannot insert 'https://graph.facebook.com/v17.0/<id>/users?access_<redacted>&appsecret_proof=<redacted>&payload=<redacted url encoded str 699 chars long>...
File "ddtrace/span.py", line 542, in __exit__
self.finish()
File "ddtrace/span.py", line 265, in finish
self._finish_ns(time_ns())
File "ddtrace/span.py", line 278, in _finish_ns
cb(self)
File "ddtrace/tracer.py", line 813, in _on_span_finish
p.on_span_finish(span)
File "ddtrace/internal/processor/trace.py", line 249, in on_span_finish
self._writer.write(spans)
File "ddtrace/internal/writer/writer.py", line 355, in write
self._write_with_client(client, spans=spans)
File "ddtrace/internal/writer/writer.py", line 377, in _write_with_client
client.encoder.put(spans)
File "ddtrace/internal/_encoding.pyx", line 733, in ddtrace.internal._encoding.MsgpackEncoderV05.put
File "ddtrace/internal/_encoding.pyx", line 734, in ddtrace.internal._encoding.MsgpackEncoderV05.put
File "ddtrace/internal/_encoding.pyx", line 740, in ddtrace.internal._encoding.MsgpackEncoderV05.put
File "ddtrace/internal/_encoding.pyx", line 737, in ddtrace.internal._encoding.MsgpackEncoderV05.put
File "ddtrace/internal/_encoding.pyx", line 491, in ddtrace.internal._encoding.MsgpackEncoderBase.put
File "ddtrace/internal/_encoding.pyx", line 495, in ddtrace.internal._encoding.MsgpackEncoderBase.put
File "ddtrace/internal/_encoding.pyx", line 518, in ddtrace.internal._encoding.MsgpackEncoderBase.put
File "ddtrace/internal/_encoding.pyx", line 499, in ddtrace.internal._encoding.MsgpackEncoderBase.put
File "ddtrace/internal/_encoding.pyx", line 483, in ddtrace.internal._encoding.MsgpackEncoderBase._pack_trace
The payload is obviously very large
@gbadnmo Have you considered adjusting the DD_TRACE_WRITER_BUFFER_SIZE_BYTES environment variable to make the buffer large enough to contain all of the span attributes?
@emmettbutler Trying with double the buffer size. Not sure if it'll work though since the payload basically looks like abuse of query params in the facebook sdk.
I'm closing this due to inactivity. Please reopen, or consider opening a new ticket, if the issue persists.
Summary of problem
Something breaks internally in
ddtrace
when the string size is larger than the default buffer size which is 8MB.Which version of dd-trace-py are you using?
1.11.0
Which version of pip are you using?
pip 23.0.1
Which libraries and their versions are you using?
How can we reproduce your problem?
There is not yet a clear pattern of what is producing this, but my gut feeling is that ddtrace tries to serialize a very long SQL query or string and it causes something to break internally.
What is the result that you get?
What is the result that you expected?
Investigation I did
1.11.0
. I am using1.11.1
but still the issue persists.The root cause according to me is:
The following code snippet is from
cdef insert()
which is ininternals/_encoding.pyx
According to my assumption, the length of the string is less than the max size in the first
if condition
, so the string is not dropped. And in the secondif condition
when we add the existing string length withself.pk.length
which is 6. We exceed the max size and end up throwing the value error.self.pk.length = MSGPACK_STRING_TABLE_LENGTH_PREFIX_SIZE
andDEF MSGPACK_STRING_TABLE_LENGTH_PREFIX_SIZE = 6