Commit cb583b2f authored by Aleksey Midenkov's avatar Aleksey Midenkov

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).
parent dcd66c38
......@@ -57,11 +57,11 @@ tttttttttttttttttttttttt❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎
set @@debug_dbug="+d,ddl_log_create_after_save_backup", @debug_crash_counter=1;
create or replace table tttttttttttttttttttttttt❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎ (z int);
ERROR HY000: Lost connection to server during query
#sql-backup-PID-TID-tttttttttttttttttttttttt@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e.MYD
#sql-backup-PID-TID-tttttttttttttttttttttttt@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e.MYI
#sql-backup-PID-TID-tttttttttttttttttttttttt@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e.frm
#sql-create-PID-TID-tttttttttttttttttttttttt@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e.MYD
#sql-create-PID-TID-tttttttttttttttttttttttt@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e.MYI
#sql-create-PID-TID-tttttttttttttttttttttttt@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e.frm
#sql-backup-PID-TID-tttttttttttttttttttttttt@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e.MYD
#sql-backup-PID-TID-tttttttttttttttttttttttt@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e.MYI
#sql-backup-PID-TID-tttttttttttttttttttttttt@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e.frm
#sql-create-PID-TID-tttttttttttttttttttttttt@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e.MYD
#sql-create-PID-TID-tttttttttttttttttttttttt@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e.MYI
#sql-create-PID-TID-tttttttttttttttttttttttt@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e@274e.frm
drop table tttttttttttttttttttttttt❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎;
set @@debug_dbug="";
......@@ -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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment