{"action":"closed","issue":{"url":"https://api.github.com/repos/facebook/mysql-5.6/issues/122","labels_url":"https://api.github.com/repos/facebook/mysql-5.6/issues/122/labels{/name}","comments_url":"https://api.github.com/repos/facebook/mysql-5.6/issues/122/comments","events_url":"https://api.github.com/repos/facebook/mysql-5.6/issues/122/events","html_url":"https://github.com/facebook/mysql-5.6/issues/122","id":121367845,"number":122,"title":"Change \"static rocksdb::DBOptions db_options\" to not static","user":{"login":"yoshinorim","id":253614,"avatar_url":"https://avatars.githubusercontent.com/u/253614?v=3","gravatar_id":"","url":"https://api.github.com/users/yoshinorim","html_url":"https://github.com/yoshinorim","followers_url":"https://api.github.com/users/yoshinorim/followers","following_url":"https://api.github.com/users/yoshinorim/following{/other_user}","gists_url":"https://api.github.com/users/yoshinorim/gists{/gist_id}","starred_url":"https://api.github.com/users/yoshinorim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yoshinorim/subscriptions","organizations_url":"https://api.github.com/users/yoshinorim/orgs","repos_url":"https://api.github.com/users/yoshinorim/repos","events_url":"https://api.github.com/users/yoshinorim/events{/privacy}","received_events_url":"https://api.github.com/users/yoshinorim/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/facebook/mysql-5.6/labels/bootcampable","name":"bootcampable","color":"f7c6c7"},{"url":"https://api.github.com/repos/facebook/mysql-5.6/labels/myrocks","name":"myrocks","color":"fef2c0"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-12-09T23:43:45Z","updated_at":"2015-12-14T23:00:00Z","closed_at":"2015-12-14T23:00:00Z","body":"By default, RocksDB initializes ThreadLocal, then initializes PosixEnv via static initializer.\r\nDestructor terminates objects in reverse order, so terminating PosixEnv (calling pthread_mutex_lock), then ThreadLocal (calling pthread_mutex_destroy). This ordering doesn't cause problems.\r\n\r\nMyRocks accidentally changed the initialization ordering. MyRocks has a static variable rocksdb::DBOptions and initializes it via static initializer function init_db_options(). ha_rocksdb.cc seems to be initialized earlier than any other rocksdb src files. rocksdb::DBOptions::DBOptions() calls PosixEnv(), so PosixEnv is initialized here. After that, RocksDB initializes ThreadLocal. So initialization ordering has changed to PosixEnv->ThreadLocal ordering. Destructor terminates in ~ThreadLocal->~PosixEnv order, so pthread_mutex_destroy() is called earlier than pthread_mutex_lock. This may cause assertion error in RocksDB at shutdown.\r\n\r\nI tried not to use static db_options in ha_rocksdb.cc, then no more assertion error has happened."}}