Skip to content

Commit b5dab19

Browse files
committed
MDEV-24757 : fix potential null pointer dereference in I_S.thread_pool_queues
With the fix, new connection without THDs will now show NULL in thread_pool_queues.CONNECTION_ID.
1 parent e2c571a commit b5dab19

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

mysql-test/main/thread_pool_info.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Field Type Null Key Default Extra
3131
GROUP_ID int(6) NO 0
3232
POSITION int(6) NO 0
3333
PRIORITY int(1) NO 0
34-
CONNECTION_ID bigint(19) unsigned NO 0
34+
CONNECTION_ID bigint(19) unsigned YES NULL
3535
QUEUEING_TIME_MICROSECONDS bigint(19) NO 0
3636
DESC INFORMATION_SCHEMA.THREAD_POOL_STATS;
3737
Field Type Null Key Default Extra

sql/thread_pool_info.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ static ST_FIELD_INFO queues_field_info[] =
9292
Column("GROUP_ID", SLong(6), NOT_NULL),
9393
Column("POSITION", SLong(6), NOT_NULL),
9494
Column("PRIORITY", SLong(1), NOT_NULL),
95-
Column("CONNECTION_ID", ULonglong(19), NOT_NULL),
95+
Column("CONNECTION_ID", ULonglong(19), NULLABLE),
9696
Column("QUEUEING_TIME_MICROSECONDS", SLonglong(19), NOT_NULL),
9797
CEnd()
9898
};
@@ -130,7 +130,8 @@ static int queues_fill_table(THD* thd, TABLE_LIST* tables, COND*)
130130
/* PRIORITY */
131131
table->field[2]->store(prio, true);
132132
/* CONNECTION_ID */
133-
table->field[3]->store(c->thd->thread_id, true);
133+
if (c->thd)
134+
table->field[3]->store(c->thd->thread_id, true);
134135
/* QUEUEING_TIME */
135136
table->field[4]->store(now - c->enqueue_time, true);
136137

0 commit comments

Comments
 (0)