MDEV-35646: Limit pseudo_thread_id
to UINT32_MAX
#3721
+3
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What problem is the patch trying to solve?
Although the
my_thread_id
type is 64 bits, binlog format specs limits it to 32 bits in practice. (See also: MDEV-35706)The writable SQL variable
pseudo_thread_id
didn’t realize this though and had a range ofULONGLONG_MAX
(at leastUINT64_MAX
in C/C++).It consequentially accepted larger values silently, but only the lower 32 bits of whom gets binlogged; this could lead to inconsistency.
Release Notes
The internal variable
pseudo_thread_id
is now limited to 32 unsigned bits (max. 4294967295) to match the range ofthread_id
.How can this PR be tested?
The MTR tests
sys_vars.sysvars_server_notembedded
andsys_vars.sysvars_server_embedded
covers the SQL variablepseudo_thread_id
itself.I got tangled by our
#include
struture, so I split my plan to fix the aformentioned inconsistency once and for all to MDEV-35706. Solving this would also remedy any truncation that originates not from the user but from our own 🍝.I skimmed through
git grep pseudo_thread_id
and found not much though, so capping the SQL variable should be sufficient (unless the system vars constructor is broken).Basing the PR against the correct MariaDB version
main
branch.PR quality check