Lets imagine following call sequence:
connection_abort
threadpool_remove_connection
unlink_thd
thd_cleanup
THD::cleanup
close_temporary_tables
MYSQL_BIN_LOG::write
MYSQL_BIN_LOG::rotate
MYSQL_BIN_LOG::new_file_without_locking
MYSQL_BIN_LOG::new_file_impl
MYSQL_BIN_LOG::close
MYSQL_LOG::close
inline_mysql_file_sync
my_sync
before_sync_wait = tp_wait_begin
wait_begin
If there was only one client connection at the moment, assertion
(thread_group->connection_count > 0) will trigger.
In fact this happens constantly on rpl_rotate_logs.test in Percona Server 5.5
with threadpool. I cannot reproduce it in MariaDB 5.5 but after looking into
source code I think similar case might be possible.
Stack trace from PS:
Assertion failed: (thread_group->connection_count > 0), function wait_begin, file /Users/sergei/percona/repo/55-tp/Percona-Server-5.5.28-rel29.1/sql/threadpool_unix.cc, line 1150.
#0 0x00007fff9014fce2 in __pthread_kill ()
#1 0x00007fff85cac7d2 in pthread_kill ()
#2 0x00007fff85c9da7a in abort ()
#3 0x00007fff85cd05de in __assert_rtn ()
#4 0x00000001002d635c in wait_begin (thread_group=<value temporarily unavailable, due to optimizations>)
at threadpool_unix.cc:1150
#5 0x00000001002d63ac in tp_wait_begin (thd=0x101169600, type=6) at threadpool_unix.cc:1290
#6 0x00000001002f8337 in my_sync (fd=76, my_flags=108822512) at my_sync.c:60
#7 0x00000001000c0d7a in MYSQL_LOG::close (this=0x100a062c8, exiting=3) at mysql_file.h:1423
#8 0x00000001000c121b in MYSQL_BIN_LOG::close (this=0x100a062c0, exiting=3) at log.cc:6089
#9 0x00000001000c6d30 in MYSQL_BIN_LOG::new_file_impl (this=0x1067c8620, need_lock=false) at log.cc:4454
#10 0x00000001000c6f82 in MYSQL_BIN_LOG::new_file_without_locking ()
at /Users/sergei/percona/repo/55-tp/Percona-Server/sql/log.cc:4358
#11 0x00000001000c6f82 in MYSQL_BIN_LOG::rotate (this=0x100a062c0, check_purge=0x1067c86de, force_rotate=false)
at log.cc:5353
#12 0x00000001000c89a1 in MYSQL_BIN_LOG::write (this=0x1067c8910, event_info=0x1067c8910) at log.cc:5234
#13 0x0000000100165891 in close_temporary_tables (thd=0x1067c8c50) at sql_base.cc:1778
#14 0x0000000100183b16 in THD::cleanup (this=0x101169600) at sql_class.cc:1500
#15 0x00000001000f1aa2 in unlink_thd (thd=0x101169600) at mysqld.cc:2131
#16 0x00000001002a781c in threadpool_remove_connection (thd=0x101169600) at threadpool_common.cc:175
#17 0x00000001002d5a98 in connection_abort [inlined] ()
at /Users/sergei/percona/repo/55-tp/Percona-Server/sql/threadpool_unix.cc:1255
#18 0x00000001002d5a98 in handle_event [inlined] ()
at /Users/sergei/percona/repo/55-tp/Percona-Server/sql/threadpool_unix.cc:1452
#19 0x00000001002d5a98 in worker_main (param=0x1067c8ee0) at threadpool_unix.cc:1489
#20 0x0000000100465e24 in pfs_spawn_thread (arg=0x1061a1360) at pfs.cc:1015
#21 0x00007fff85caa8bf in _pthread_start ()
#22 0x00007fff85cadb75 in thread_start ()
{"report":{"fcp":873.8999996185303,"ttfb":291,"pageVisibility":"visible","entityId":22751,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":1,"journeyId":"c6effb14-b699-4c77-8dfb-e75a000921b1","navigationType":0,"readyForUser":946.0999994277954,"redirectCount":0,"resourceLoadedEnd":1073.5,"resourceLoadedStart":297.5999994277954,"resourceTiming":[{"duration":43.5,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bv2/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":297.5999994277954,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":297.5999994277954,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":341.0999994277954,"responseStart":0,"secureConnectionStart":0},{"duration":43.5,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2bv2/820016/12ta74/2380add21a9a1006587582385952de73/_/download/contextbatch/css/jira.browse.project,project.issue.navigator,jira.view.issue,jira.general,jira.global,atl.general,-_super/batch.css?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true","startTime":297.8999996185303,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":297.8999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":341.3999996185303,"responseStart":0,"secureConnectionStart":0},{"duration":111.30000019073486,"initiatorType":"script","name":"https://jira.mariadb.org/s/e9b27a47da5fb0f74a35acd57e9847fb-CDN/lu2bv2/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":298,"connectEnd":298,"connectStart":298,"domainLookupEnd":298,"domainLookupStart":298,"fetchStart":298,"redirectEnd":0,"redirectStart":0,"requestStart":298,"responseEnd":409.30000019073486,"responseStart":409.30000019073486,"secureConnectionStart":298},{"duration":200.19999980926514,"initiatorType":"script","name":"https://jira.mariadb.org/s/c32eb0da7ad9831253f8397e6cc26afd-CDN/lu2bv2/820016/12ta74/2380add21a9a1006587582385952de73/_/download/contextbatch/js/jira.browse.project,project.issue.navigator,jira.view.issue,jira.general,jira.global,atl.general,-_super/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&locale=en&slack-enabled=true","startTime":298.19999980926514,"connectEnd":298.19999980926514,"connectStart":298.19999980926514,"domainLookupEnd":298.19999980926514,"domainLookupStart":298.19999980926514,"fetchStart":298.19999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":298.19999980926514,"responseEnd":498.3999996185303,"responseStart":498.3999996185303,"secureConnectionStart":298.19999980926514},{"duration":204.0999994277954,"initiatorType":"script","name":"https://jira.mariadb.org/s/bc0bcb146314416123c992714ee00ff7-CDN/lu2bv2/820016/12ta74/c92c0caa9a024ae85b0ebdbed7fb4bd7/_/download/contextbatch/js/atl.global,-_super/batch.js?locale=en","startTime":298.30000019073486,"connectEnd":298.30000019073486,"connectStart":298.30000019073486,"domainLookupEnd":298.30000019073486,"domainLookupStart":298.30000019073486,"fetchStart":298.30000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":298.30000019073486,"responseEnd":502.3999996185303,"responseStart":502.3999996185303,"secureConnectionStart":298.30000019073486},{"duration":204.20000076293945,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bv2/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-en/jira.webresources:calendar-en.js","startTime":298.5999994277954,"connectEnd":298.5999994277954,"connectStart":298.5999994277954,"domainLookupEnd":298.5999994277954,"domainLookupStart":298.5999994277954,"fetchStart":298.5999994277954,"redirectEnd":0,"redirectStart":0,"requestStart":298.5999994277954,"responseEnd":502.80000019073486,"responseStart":502.80000019073486,"secureConnectionStart":298.5999994277954},{"duration":204.39999961853027,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bv2/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-localisation-moment/jira.webresources:calendar-localisation-moment.js","startTime":298.80000019073486,"connectEnd":298.80000019073486,"connectStart":298.80000019073486,"domainLookupEnd":298.80000019073486,"domainLookupStart":298.80000019073486,"fetchStart":298.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":298.80000019073486,"responseEnd":503.19999980926514,"responseStart":503.19999980926514,"secureConnectionStart":298.80000019073486},{"duration":257,"initiatorType":"link","name":"https://jira.mariadb.org/s/b04b06a02d1959df322d9cded3aeecc1-CDN/lu2bv2/820016/12ta74/a2ff6aa845ffc9a1d22fe23d9ee791fc/_/download/contextbatch/css/jira.global.look-and-feel,-_super/batch.css","startTime":298.8999996185303,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":298.8999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":555.8999996185303,"responseStart":0,"secureConnectionStart":0},{"duration":204.60000038146973,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":299.0999994277954,"connectEnd":299.0999994277954,"connectStart":299.0999994277954,"domainLookupEnd":299.0999994277954,"domainLookupStart":299.0999994277954,"fetchStart":299.0999994277954,"redirectEnd":0,"redirectStart":0,"requestStart":299.0999994277954,"responseEnd":503.69999980926514,"responseStart":503.69999980926514,"secureConnectionStart":299.0999994277954},{"duration":256.79999923706055,"initiatorType":"link","name":"https://jira.mariadb.org/s/3ac36323ba5e4eb0af2aa7ac7211b4bb-CDN/lu2bv2/820016/12ta74/d176f0986478cc64f24226b3d20c140d/_/download/contextbatch/css/com.atlassian.jira.projects.sidebar.init,-_super,-project.issue.navigator,-jira.view.issue/batch.css?jira.create.linked.issue=true","startTime":299.30000019073486,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":299.30000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":556.0999994277954,"responseStart":0,"secureConnectionStart":0},{"duration":204.9000005722046,"initiatorType":"script","name":"https://jira.mariadb.org/s/719848dd97ebe0663199f49a3936487a-CDN/lu2bv2/820016/12ta74/d176f0986478cc64f24226b3d20c140d/_/download/contextbatch/js/com.atlassian.jira.projects.sidebar.init,-_super,-project.issue.navigator,-jira.view.issue/batch.js?jira.create.linked.issue=true&locale=en","startTime":299.3999996185303,"connectEnd":299.3999996185303,"connectStart":299.3999996185303,"domainLookupEnd":299.3999996185303,"domainLookupStart":299.3999996185303,"fetchStart":299.3999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":299.3999996185303,"responseEnd":504.30000019073486,"responseStart":504.30000019073486,"secureConnectionStart":299.3999996185303},{"duration":772.6000003814697,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bv2/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-js/jira.webresources:bigpipe-js.js","startTime":300.19999980926514,"connectEnd":300.19999980926514,"connectStart":300.19999980926514,"domainLookupEnd":300.19999980926514,"domainLookupStart":300.19999980926514,"fetchStart":300.19999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":300.19999980926514,"responseEnd":1072.8000001907349,"responseStart":1072.8000001907349,"secureConnectionStart":300.19999980926514},{"duration":773.1999998092651,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bv2/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-init/jira.webresources:bigpipe-init.js","startTime":300.30000019073486,"connectEnd":300.30000019073486,"connectStart":300.30000019073486,"domainLookupEnd":300.30000019073486,"domainLookupStart":300.30000019073486,"fetchStart":300.30000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":300.30000019073486,"responseEnd":1073.5,"responseStart":1073.5,"secureConnectionStart":300.30000019073486},{"duration":321.30000019073486,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":568.0999994277954,"connectEnd":568.0999994277954,"connectStart":568.0999994277954,"domainLookupEnd":568.0999994277954,"domainLookupStart":568.0999994277954,"fetchStart":568.0999994277954,"redirectEnd":0,"redirectStart":0,"requestStart":568.0999994277954,"responseEnd":889.3999996185303,"responseStart":889.3999996185303,"secureConnectionStart":568.0999994277954},{"duration":266.5999994277954,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":867.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":867.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1134.0999994277954,"responseStart":0,"secureConnectionStart":0}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":151,"responseStart":291,"responseEnd":295,"domLoading":295,"domInteractive":1090,"domContentLoadedEventStart":1090,"domContentLoadedEventEnd":1130,"domComplete":2001,"loadEventStart":2001,"loadEventEnd":2003,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1076.8000001907349},{"name":"bigPipe.sidebar-id.end","time":1077.5999994277954},{"name":"bigPipe.activity-panel-pipe-id.start","time":1077.8000001907349},{"name":"bigPipe.activity-panel-pipe-id.end","time":1080.3000001907349},{"name":"activityTabFullyLoaded","time":1139.3000001907349}],"measures":[],"correlationId":"5a99bd4c41282d","effectiveType":"4g","downlink":9.8,"rtt":0,"serverDuration":86,"dbReadsTimeInMs":8,"dbConnsTimeInMs":15,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}