Skip to content

Commit a70f7aa

Browse files
montywivuvova
authored andcommitted
Print thread_id instead of pthread_self to error log
- Now we have same thread_id in general log, slow long and error log instead of a long meaningless thread number that may even change for one user. - Align error and slow log header with output - Extend thread_id with one number to handle nice printing up to ten million connections
1 parent af06683 commit a70f7aa

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

sql/log.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2672,7 +2672,7 @@ bool MYSQL_LOG::open(
26722672
mysqld_port, mysqld_unix_port
26732673
#endif
26742674
);
2675-
end= strnmov(buff + len, "Time Id Command Argument\n",
2675+
end= strnmov(buff + len, "Time\t\t Id Command\tArgument\n",
26762676
sizeof(buff) - len);
26772677
if (my_b_write(&log_file, (uchar*) buff, (uint) (end-buff)) ||
26782678
flush_io_cache(&log_file))
@@ -2907,7 +2907,7 @@ bool MYSQL_QUERY_LOG::write(time_t event_time, const char *user_host,
29072907
goto err;
29082908

29092909
/* command_type, thread_id */
2910-
size_t length= my_snprintf(buff, 32, "%5llu ", thread_id_arg);
2910+
size_t length= my_snprintf(buff, 32, "%6llu ", thread_id_arg);
29112911

29122912
if (my_b_write(&log_file, (uchar*) buff, length))
29132913
goto err;
@@ -8460,7 +8460,7 @@ static void print_buffer_to_file(enum loglevel level, const char *buffer,
84608460
time_t skr;
84618461
struct tm tm_tmp;
84628462
struct tm *start;
8463-
THD *thd;
8463+
THD *thd= 0;
84648464
int tag_length= 0;
84658465
char tag[NAME_LEN];
84668466
DBUG_ENTER("print_buffer_to_file");
@@ -8494,7 +8494,7 @@ static void print_buffer_to_file(enum loglevel level, const char *buffer,
84948494
start->tm_hour,
84958495
start->tm_min,
84968496
start->tm_sec,
8497-
(unsigned long) pthread_self(),
8497+
(unsigned long) (thd ? thd->thread_id : 0),
84988498
(level == ERROR_LEVEL ? "ERROR" : level == WARNING_LEVEL ?
84998499
"Warning" : "Note"),
85008500
tag_length, tag,

0 commit comments

Comments
 (0)