-
Notifications
You must be signed in to change notification settings - Fork 454
CDRIVER-4485 string append and truncation fixes for structured logging #1826
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…tring APIs Adds the truncation marker, defines string limits carefully to avoid bson length overflow or int overflow
return an error in the event the sequence has < 4 bytes of unexpected data at the end. previously, this extra data was silently ignored.
src/libmongoc/doc/mongoc_structured_log_opts_get_max_document_length.rst
Outdated
Show resolved
Hide resolved
src/libmongoc/doc/mongoc_structured_log_opts_set_max_document_length.rst
Outdated
Show resolved
Hide resolved
src/libmongoc/tests/test-mongoc-command-logging-and-monitoring.c
Outdated
Show resolved
Hide resolved
…length.rst Co-authored-by: Ezra Chung <88335979+eramongodb@users.noreply.github.com>
…length.rst Co-authored-by: Ezra Chung <88335979+eramongodb@users.noreply.github.com>
Co-authored-by: Ezra Chung <88335979+eramongodb@users.noreply.github.com>
Expect a very slight microarchitectural speed boost if this path is ever hot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple more suggestions; otherwise, LGTM.
src/libmongoc/doc/mongoc_structured_log_opts_get_max_document_length.rst
Outdated
Show resolved
Hide resolved
…length.rst Co-authored-by: Ezra Chung <88335979+eramongodb@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One last suggestion; otherwise, LGTM. 👍
@@ -142,6 +143,7 @@ test_structured_log_plain (void) | |||
|
|||
mongoc_structured_log_opts_t *opts = mongoc_structured_log_opts_new (); | |||
mongoc_structured_log_opts_set_handler (opts, structured_log_func, &assumption); | |||
ASSERT (mongoc_structured_log_opts_set_max_document_length (opts, 10000)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ASSERT (mongoc_structured_log_opts_set_max_document_length (opts, 10000)); | |
ASSERT ( | |
mongoc_structured_log_opts_set_max_document_length (opts, MONGOC_STRUCTURED_LOG_DEFAULT_MAX_DOCUMENT_LENGTH)); |
Should these values of 10000
be MONGOC_STRUCTURED_LOG_DEFAULT_MAX_DOCUMENT_LENGTH
(1000) instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The specific value doesn't really matter as long as it's more than the small lengths used in the test, but my intent was to follow the advice from the CLAM spec:
"Drivers MUST run the logging tests with their max document
length setting (as described in the logging specification)
set to a large value e.g. 10,000; this is necessary in order for the driver to emit the full server reply (and to allow
matching against that reply) on certain MongoDB versions and topologies."
It's mostly arbitrary but I'll add a comment explaining the choice just so it doesn't seem out of place.
This PR is a follow-up for #1795 which depends on the new internal string append and json building API from #1816. (Update: Now addresses compatibility with #1821 also.)