mirror of
https://github.com/MariaDB/server.git
synced 2025-01-27 09:14:17 +01:00
MDEV-35646: Limit pseudo_thread_id
to UINT32_MAX
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. Reviewed-by: Brandon Nesterenko <brandon.nesterenko@mariadb.com>
This commit is contained in:
parent
782c4b94f0
commit
cbb24d9aa5
5 changed files with 11 additions and 4 deletions
|
@ -641,6 +641,13 @@ extern pthread_mutexattr_t my_errorcheck_mutexattr;
|
|||
#endif
|
||||
|
||||
typedef uint64 my_thread_id;
|
||||
/**
|
||||
Long-standing formats (such as the client-server protocol and the binary log)
|
||||
hard-coded `my_thread_id` to 32 bits in practice. (Though not all
|
||||
`thread_id`s are typed as such, @ref my_thread_id itself among those.)
|
||||
@see MDEV-35706
|
||||
*/
|
||||
#define MY_THREAD_ID_MAX UINT32_MAX
|
||||
|
||||
extern void my_threadattr_global_init(void);
|
||||
extern my_bool my_thread_global_init(void);
|
||||
|
|
|
@ -2877,7 +2877,7 @@ VARIABLE_SCOPE SESSION ONLY
|
|||
VARIABLE_TYPE BIGINT UNSIGNED
|
||||
VARIABLE_COMMENT This variable is for internal server use
|
||||
NUMERIC_MIN_VALUE 0
|
||||
NUMERIC_MAX_VALUE 18446744073709551615
|
||||
NUMERIC_MAX_VALUE 4294967295
|
||||
NUMERIC_BLOCK_SIZE 1
|
||||
ENUM_VALUE_LIST NULL
|
||||
READ_ONLY NO
|
||||
|
|
|
@ -3037,7 +3037,7 @@ VARIABLE_SCOPE SESSION ONLY
|
|||
VARIABLE_TYPE BIGINT UNSIGNED
|
||||
VARIABLE_COMMENT This variable is for internal server use
|
||||
NUMERIC_MIN_VALUE 0
|
||||
NUMERIC_MAX_VALUE 18446744073709551615
|
||||
NUMERIC_MAX_VALUE 4294967295
|
||||
NUMERIC_BLOCK_SIZE 1
|
||||
ENUM_VALUE_LIST NULL
|
||||
READ_ONLY NO
|
||||
|
|
|
@ -9770,7 +9770,7 @@ void init_server_psi_keys(void)
|
|||
|
||||
*/
|
||||
|
||||
static my_thread_id thread_id_max= UINT_MAX32;
|
||||
static my_thread_id thread_id_max= MY_THREAD_ID_MAX;
|
||||
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
|
|
@ -1767,7 +1767,7 @@ Sys_pseudo_thread_id(
|
|||
"pseudo_thread_id",
|
||||
"This variable is for internal server use",
|
||||
SESSION_ONLY(pseudo_thread_id),
|
||||
NO_CMD_LINE, VALID_RANGE(0, ULONGLONG_MAX), DEFAULT(0),
|
||||
NO_CMD_LINE, VALID_RANGE(0, MY_THREAD_ID_MAX), DEFAULT(0),
|
||||
BLOCK_SIZE(1), NO_MUTEX_GUARD, IN_BINLOG);
|
||||
|
||||
static bool
|
||||
|
|
Loading…
Add table
Reference in a new issue