Skip to content

Commit 8185c25

Browse files
yoshinorimGunnar Kudrjavets
authored andcommitted
Fixing occasional MyRocks SIGABRT on shutdown (mysql#122)
Summary: RocksDB has some static object dependencies, and without following dependencies, it hits SIGABRT. This diff has two fixes. 1. Updating RocksDB revision. D51789 in RocksDB changes the problematic mutex from global variable to local (function-level) static variable. 2. Changing MyRocks no to call ddl_manager.persist_stats() by kill_server_thread (which calls rocksdb_done_func()). By calling ddl_manager.persist_stats(), rocksdb::ThreadLocalPtr::StaticMeta::OnThreadExit() (which calls pthread_mutex_lock on "static port::Mutex mutex") is called at the end of the thread. On the other hand, there is a race between main thread and kill_server_thread. main thread calls pthread_mutex_destroy for the mutex. To guarantee not to call pthread_mutex_lock() after pthread_mutex_destroy(), it is necessary not to call ddl_manager.persist_stats() from kill_server_thread. This diff fixes the issue. @update-submodule: rocksdb Test Plan: mtr cardinality --repeat=100 Reviewers: hermanlee4, spetrunia, jkedgar Reviewed By: jkedgar Subscribers: yhchiang, webscalesql-eng Differential Revision: https://reviews.facebook.net/D51933
1 parent 8efdec8 commit 8185c25

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

storage/rocksdb/ha_rocksdb.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2402,9 +2402,6 @@ static int rocksdb_done_func(void *p)
24022402
mysql_mutex_lock(&background_mutex);
24032403
mysql_mutex_unlock(&background_mutex);
24042404

2405-
// save remaining stats which might've left unsaved
2406-
ddl_manager.persist_stats();
2407-
24082405
// wait for the drop index thread to finish
24092406
mysql_mutex_lock(&drop_index_mutex);
24102407
mysql_mutex_unlock(&drop_index_mutex);
@@ -6987,6 +6984,9 @@ void* background_thread(void*)
69876984
}
69886985
}
69896986

6987+
// save remaining stats which might've left unsaved
6988+
ddl_manager.persist_stats();
6989+
69906990
mysql_mutex_unlock(&background_mutex);
69916991

69926992
return nullptr;

0 commit comments

Comments
 (0)