Skip to content

Commit 200430e

Browse files
author
Jan Lindström
committed
MDEV-10845: Server crashes in sync_array_cell_print with innodb-status-file
Problem was NULL-pointer reference. Fixed by removing unnecessary and not really working recursive reserver thread lookup.
1 parent 4368efe commit 200430e

File tree

1 file changed

+9
-78
lines changed

1 file changed

+9
-78
lines changed

storage/innobase/sync/sync0arr.cc

Lines changed: 9 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -501,9 +501,7 @@ void
501501
sync_array_cell_print(
502502
/*==================*/
503503
FILE* file, /*!< in: file where to print */
504-
sync_cell_t* cell, /*!< in: sync cell */
505-
os_thread_id_t* reserver) /*!< out: write reserver or
506-
0 */
504+
sync_cell_t* cell) /*!< in: sync cell */
507505
{
508506
rw_lock_t* rwlock;
509507
ulint type;
@@ -601,7 +599,6 @@ sync_array_cell_print(
601599
writer == RW_LOCK_X ? " exclusive\n"
602600
: writer == RW_LOCK_SX ? " SX\n"
603601
: " wait exclusive\n");
604-
*reserver = rwlock->writer_thread;
605602
}
606603

607604
fprintf(file,
@@ -715,7 +712,7 @@ sync_array_report_error(
715712
sync_cell_t* cell)
716713
{
717714
fprintf(stderr, "rw-lock %p ", (void*) lock);
718-
sync_array_cell_print(stderr, cell, 0);
715+
sync_array_cell_print(stderr, cell);
719716
rw_lock_debug_print(stderr, debug);
720717
}
721718

@@ -788,7 +785,7 @@ sync_array_detect_deadlock(
788785
<< " file " << name << " line "
789786
<< policy.get_enter_line();
790787

791-
sync_array_cell_print(stderr, cell, 0);
788+
sync_array_cell_print(stderr, cell);
792789

793790
return(true);
794791
}
@@ -1152,7 +1149,7 @@ sync_array_print_long_waits_low(
11521149

11531150
if (diff > SYNC_ARRAY_TIMEOUT) {
11541151
ib::warn() << "A long semaphore wait:";
1155-
sync_array_cell_print(stderr, cell, 0);
1152+
sync_array_cell_print(stderr, cell);
11561153
*noticed = TRUE;
11571154
}
11581155

@@ -1167,14 +1164,12 @@ sync_array_print_long_waits_low(
11671164
}
11681165
}
11691166

1170-
/* We found a long semaphore wait, wait all threads that are
1167+
/* We found a long semaphore wait, print all threads that are
11711168
waiting for a semaphore. */
11721169
if (*noticed) {
11731170
for (i = 0; i < arr->n_cells; i++) {
11741171
void* wait_object;
1175-
os_thread_id_t reserver=(os_thread_id_t)ULINT_UNDEFINED;
11761172
sync_cell_t* cell;
1177-
ulint loop = 0;
11781173

11791174
cell = sync_array_get_nth_cell(arr, i);
11801175

@@ -1185,41 +1180,8 @@ sync_array_print_long_waits_low(
11851180
continue;
11861181
}
11871182

1188-
fputs("InnoDB: Warning: semaphore wait:\n",
1189-
stderr);
1190-
sync_array_cell_print(stderr, cell, 0);
1191-
1192-
/* Try to output cell information for writer recursive way */
1193-
while (reserver != (os_thread_id_t)ULINT_UNDEFINED) {
1194-
sync_cell_t* reserver_wait;
1195-
1196-
reserver_wait = sync_array_find_thread(arr, reserver);
1197-
1198-
if (reserver_wait &&
1199-
reserver_wait->latch.mutex != NULL &&
1200-
reserver_wait->waiting) {
1201-
fputs("InnoDB: Warning: Writer thread is waiting this semaphore:\n",
1202-
stderr);
1203-
reserver = (os_thread_id_t)ULINT_UNDEFINED;
1204-
sync_array_cell_print(stderr, reserver_wait, &reserver);
1205-
loop++;
1206-
1207-
/* TODO: FIXME:
1208-
if (reserver_wait->thread == reserver) {
1209-
reserver = (os_thread_id_t)ULINT_UNDEFINED;
1210-
}
1211-
*/
1212-
} else {
1213-
reserver = (os_thread_id_t)ULINT_UNDEFINED;
1214-
}
1215-
1216-
/* This is protection against loop */
1217-
if (loop > 100) {
1218-
fputs("InnoDB: Warning: Too many waiting threads.\n", stderr);
1219-
break;
1220-
}
1221-
1222-
}
1183+
ib::info() << "A semaphore wait:";
1184+
sync_array_cell_print(stderr, cell);
12231185
}
12241186
}
12251187

@@ -1314,7 +1276,7 @@ sync_array_print_info_low(
13141276

13151277
if (cell->latch.mutex != 0) {
13161278
count++;
1317-
sync_array_cell_print(file, cell, 0);
1279+
sync_array_cell_print(file, cell);
13181280
}
13191281
}
13201282
}
@@ -1404,8 +1366,6 @@ sync_array_print_innodb(void)
14041366
for (i = 0; i < arr->n_cells; i++) {
14051367
void* wait_object;
14061368
sync_cell_t* cell;
1407-
os_thread_id_t reserver=(os_thread_id_t)ULINT_UNDEFINED;
1408-
ulint loop=0;
14091369

14101370
cell = sync_array_get_nth_cell(arr, i);
14111371

@@ -1418,36 +1378,7 @@ sync_array_print_innodb(void)
14181378

14191379
fputs("InnoDB: Warning: semaphore wait:\n",
14201380
stderr);
1421-
sync_array_cell_print(stderr, cell, &reserver);
1422-
1423-
/* Try to output cell information for writer recursive way */
1424-
while (reserver != (os_thread_id_t)ULINT_UNDEFINED) {
1425-
sync_cell_t* reserver_wait;
1426-
1427-
reserver_wait = sync_array_find_thread(arr, reserver);
1428-
1429-
if (reserver_wait &&
1430-
reserver_wait->latch.mutex != NULL &&
1431-
reserver_wait->waiting) {
1432-
fputs("InnoDB: Warning: Writer thread is waiting this semaphore:\n",
1433-
stderr);
1434-
sync_array_cell_print(stderr, reserver_wait, &reserver);
1435-
1436-
/* JAN: FIXME:
1437-
if (reserver_wait->thread == reserver) {
1438-
reserver = (os_thread_id_t)ULINT_UNDEFINED;
1439-
}
1440-
*/
1441-
} else {
1442-
reserver = (os_thread_id_t)ULINT_UNDEFINED;
1443-
}
1444-
1445-
/* This is protection against loop */
1446-
if (loop > 100) {
1447-
fputs("InnoDB: Warning: Too many waiting threads.\n", stderr);
1448-
break;
1449-
}
1450-
}
1381+
sync_array_cell_print(stderr, cell);
14511382
}
14521383

14531384
fputs("InnoDB: Semaphore wait debug output ended:\n", stderr);

0 commit comments

Comments
 (0)