Skip to content
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

MDEV-35646: Limit pseudo_thread_id to UINT32_MAX #3721

Open
wants to merge 1 commit into
base: 10.5
Choose a base branch
from

Conversation

ParadoxV5
Copy link
Contributor

  • The Jira issue number for this PR is: MDEV-35646

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 of ULONGLONG_MAX (at least UINT64_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 of thread_id.

How can this PR be tested?

The MTR tests sys_vars.sysvars_server_notembedded and sys_vars.sysvars_server_embedded covers the SQL variable pseudo_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

  • This is a new feature or a refactoring, and the PR is based against the main branch.
  • This is a bug fix, and the PR is based against the earliest maintained branch in which the bug can be reproduced.

PR quality check

  • I checked the CODING_STANDARDS.md file and my PR conforms to this where appropriate.
  • For any trivial modifications to the PR, I am ok with the reviewer making the changes themselves.

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 of `ULONGLONG_MAX` (at least `UINT64_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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

1 participant