mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
MDEV-29609 create_not_windows test fails with different result
make_tmp_name() creates temporary name with prefix containing PID and TID. This prefix influences max length of the rest of the name (the whole name is limited by NAME_LEN). During the test run PID and TID can change. PID increases when the server restarts. TID is incremented with the new connections (generated by next_thread_id(), is not the posix thread ID). During the test run PID can increase max 2 decimal positions: from tens to thousands this requires ~900 restarts. TID depends on connection count, but for test we assume it will not trespass 100000 connections which is 5 decimal positions. So it should be enough to reserve 7 characters for PID and TID increment. The patch reserves more: it reserves 12 characters for 7-decimal PID and 5-decimal TID plus 4 chars of additional reserve (for future prefix changes) and assumes minimal legth of the prefix is 30 bytes: #sql-backup-PID-TID- #sql-create-PID-TID- 4-6-PID-TID- is 10 + 4 + PID + TID, so PID + TID is 16 chars (7 + 5 + 4).
This commit is contained in:
@ -1251,13 +1251,19 @@ bool make_tmp_name(THD *thd, const char *prefix, const Table_name *orig,
|
||||
char res_name[NAME_LEN + 1];
|
||||
char file_name[NAME_LEN + 1];
|
||||
LEX_CSTRING table_name;
|
||||
/*
|
||||
Filename trimming should not depend on prefix length with variable PID and
|
||||
thread ID. This makes tests happier.
|
||||
*/
|
||||
constexpr int MIN_PREFIX= 30;
|
||||
|
||||
size_t len= my_snprintf(res_name, sizeof(res_name) - 1,
|
||||
tmp_file_prefix "-%s-%lx-%llx-", prefix,
|
||||
current_pid, thd->thread_id);
|
||||
|
||||
const size_t pfx_len= len < MIN_PREFIX ? MIN_PREFIX : len;
|
||||
uint len2= tablename_to_filename(orig->table_name.str, file_name,
|
||||
sizeof(res_name) - len - 1);
|
||||
sizeof(res_name) - pfx_len - 1);
|
||||
|
||||
DBUG_ASSERT(len + len2 < sizeof(res_name) - 1);
|
||||
memcpy(res_name + len, file_name, len2 + 1);
|
||||
|
Reference in New Issue
Block a user