valerii reported the following upstream bug that also seems to effect MariaDB:
http://bugs.mysql.com/bug.php?id=83708
We can see the same block of code in MariaDB 10.1:
https://github.com/MariaDB/server/blob/a98c85bb501e9021c0d8d509b8c040611d4c0c3a/sql/sql_table.cc#L663
and in MariaDB 10.0:
https://github.com/MariaDB/server/blob/5569ac00590ba139bbc575c20de4c682919721e5/sql/sql_table.cc#L664
and in MariaDB 5.5:
https://github.com/MariaDB/server/blob/19e3597e0c718a4cfdfe8789c7b4b11a4e0ba0c6/sql/sql_table.cc#L677
Bug description from upstream report:
Please, check the following code in sql/sql_table.cc:
|
|
static bool read_ddl_log_file_entry(uint entry_no)
|
{
|
bool error= FALSE;
|
File file_id= global_ddl_log.file_id;
|
uchar *file_entry_buf= (uchar*)global_ddl_log.file_entry_buf;
|
uint io_size= global_ddl_log.io_size;
|
DBUG_ENTER("read_ddl_log_file_entry");
|
|
mysql_mutex_assert_owner(&LOCK_gdl);
|
if (mysql_file_pread(file_id, file_entry_buf, io_size, io_size * entry_no,
|
MYF(MY_WME)) != io_size)
|
error= TRUE;
|
DBUG_RETURN(error);
|
}
|
|
I see two potential problems with it:
|
|
1. We multiply two uint values, io_size (that is typically 4096, see:
|
|
include/my_global.h:332:#define IO_SIZE 4096
|
|
etc)
|
|
and entry_no, without any type cast. The resulting expression is going to be of uint type (4 bytes long unsigned), but formal parameter of mysql_file_pread (and my_pread that it ends up defined as) is of type my_off_t. This type is 8 bytes long (on 64-bit systems) usually:
|
|
#if defined(_WIN32)
|
typedef unsigned long long my_off_t;
|
typedef unsigned long long os_off_t;
|
#else
|
typedef off_t os_off_t;
|
#if SIZEOF_OFF_T > 4
|
typedef ulonglong my_off_t;
|
#else
|
typedef unsigned long my_off_t;
|
#endif
|
#endif /*_WIN32*/
|
|
So, we may end up passing the value of 4294955008 all the time whenever entry_no > 1048573
|
|
Function to write DDL log (static bool write_ddl_log_file_entry(uint entry_no)) is affected in a similar way it seems.
|
|
2. We pass MY_WME flag, that is, we just write error to the error log in case of failure, but continue attempts to read in my_pread() indefinitely:
|
|
#define MY_FFNF 1 /* Fatal if file not found */
|
#define MY_FNABP 2 /* Fatal if not all bytes read/writen */
|
#define MY_NABP 4 /* Error if not all bytes read/writen */
|
#define MY_FAE 8 /* Fatal if any error */
|
#define MY_WME 16 /* Write message on error */
|
...
|
|
So, when offset is big enough we start to loop indefinitely, adding messages to error log and holding LOCK_gdl mutex. As a result, any concurrent DDL activity is essentially blocked forever until we get rid of ddl_log.dll file that is 4G in size.
|
|
How to repeat:
|
Read the code.
|
|
There are reasons to think that as soon as more than 1048573 entries (4096 bytes each) are written to the DDL Log (see https://dev.mysql.com/doc/refman/5.7/en/ddl-log.html) so that it becomes 4G in size, there is no way to read the entries from it successfully.
|
|
Suggested fix:
|
Make sure the value of offset passed to mysql_file_pread() and my_file_pwrite() is of type my_off_t in all cases and is not affected by artificial 4 bytes limits.
|
|
Additionally, consider other flags (MY_FNABP?) when I/O happens with some mutex hold.
|
Transition |
Time In Source Status |
Execution Times |
Open |
|
Closed |
|
3d 6h 2m
|
1
|
{"report":{"fcp":613,"ttfb":153.39999985694885,"pageVisibility":"visible","entityId":58828,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":1,"journeyId":"03c7a257-69cb-408a-bf00-92acfaa37922","navigationType":0,"readyForUser":746.2999999523163,"redirectCount":0,"resourceLoadedEnd":632.5,"resourceLoadedStart":158.29999995231628,"resourceTiming":[{"duration":6.400000095367432,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":158.29999995231628,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":158.29999995231628,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":164.70000004768372,"responseStart":0,"secureConnectionStart":0},{"duration":6.400000095367432,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2bu7/820016/12ta74/8679b4946efa1a0bb029a3a22206fb5d/_/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":158.39999985694885,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":158.39999985694885,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":164.79999995231628,"responseStart":0,"secureConnectionStart":0},{"duration":63.10000014305115,"initiatorType":"script","name":"https://jira.mariadb.org/s/fbf975c0cce4b1abf04784eeae9ba1f4-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":158.59999990463257,"connectEnd":158.59999990463257,"connectStart":158.59999990463257,"domainLookupEnd":158.59999990463257,"domainLookupStart":158.59999990463257,"fetchStart":158.59999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":158.59999990463257,"responseEnd":221.70000004768372,"responseStart":221.70000004768372,"secureConnectionStart":158.59999990463257},{"duration":146.89999985694885,"initiatorType":"script","name":"https://jira.mariadb.org/s/099b33461394b8015fc36c0a4b96e19f-CDN/lu2bu7/820016/12ta74/8679b4946efa1a0bb029a3a22206fb5d/_/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":158.70000004768372,"connectEnd":158.70000004768372,"connectStart":158.70000004768372,"domainLookupEnd":158.70000004768372,"domainLookupStart":158.70000004768372,"fetchStart":158.70000004768372,"redirectEnd":0,"redirectStart":0,"requestStart":158.70000004768372,"responseEnd":305.59999990463257,"responseStart":305.59999990463257,"secureConnectionStart":158.70000004768372},{"duration":150.5,"initiatorType":"script","name":"https://jira.mariadb.org/s/94c15bff32baef80f4096a08aceae8bc-CDN/lu2bu7/820016/12ta74/c92c0caa9a024ae85b0ebdbed7fb4bd7/_/download/contextbatch/js/atl.global,-_super/batch.js?locale=en","startTime":158.79999995231628,"connectEnd":158.79999995231628,"connectStart":158.79999995231628,"domainLookupEnd":158.79999995231628,"domainLookupStart":158.79999995231628,"fetchStart":158.79999995231628,"redirectEnd":0,"redirectStart":0,"requestStart":158.79999995231628,"responseEnd":309.2999999523163,"responseStart":309.2999999523163,"secureConnectionStart":158.79999995231628},{"duration":150.90000009536743,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-en/jira.webresources:calendar-en.js","startTime":158.89999985694885,"connectEnd":158.89999985694885,"connectStart":158.89999985694885,"domainLookupEnd":158.89999985694885,"domainLookupStart":158.89999985694885,"fetchStart":158.89999985694885,"redirectEnd":0,"redirectStart":0,"requestStart":158.89999985694885,"responseEnd":309.7999999523163,"responseStart":309.7999999523163,"secureConnectionStart":158.89999985694885},{"duration":151.09999990463257,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-localisation-moment/jira.webresources:calendar-localisation-moment.js","startTime":159,"connectEnd":159,"connectStart":159,"domainLookupEnd":159,"domainLookupStart":159,"fetchStart":159,"redirectEnd":0,"redirectStart":0,"requestStart":159,"responseEnd":310.09999990463257,"responseStart":310.09999990463257,"secureConnectionStart":159},{"duration":151.29999995231628,"initiatorType":"link","name":"https://jira.mariadb.org/s/b04b06a02d1959df322d9cded3aeecc1-CDN/lu2bu7/820016/12ta74/a2ff6aa845ffc9a1d22fe23d9ee791fc/_/download/contextbatch/css/jira.global.look-and-feel,-_super/batch.css","startTime":159.09999990463257,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":159.09999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":310.39999985694885,"responseStart":0,"secureConnectionStart":0},{"duration":151.19999980926514,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":159.20000004768372,"connectEnd":159.20000004768372,"connectStart":159.20000004768372,"domainLookupEnd":159.20000004768372,"domainLookupStart":159.20000004768372,"fetchStart":159.20000004768372,"redirectEnd":0,"redirectStart":0,"requestStart":159.20000004768372,"responseEnd":310.39999985694885,"responseStart":310.39999985694885,"secureConnectionStart":159.20000004768372},{"duration":151.59999990463257,"initiatorType":"link","name":"https://jira.mariadb.org/s/3ac36323ba5e4eb0af2aa7ac7211b4bb-CDN/lu2bu7/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":159.29999995231628,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":159.29999995231628,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":310.89999985694885,"responseStart":0,"secureConnectionStart":0},{"duration":151.70000004768372,"initiatorType":"script","name":"https://jira.mariadb.org/s/3339d87fa2538a859872f2df449bf8d0-CDN/lu2bu7/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":159.39999985694885,"connectEnd":159.39999985694885,"connectStart":159.39999985694885,"domainLookupEnd":159.39999985694885,"domainLookupStart":159.39999985694885,"fetchStart":159.39999985694885,"redirectEnd":0,"redirectStart":0,"requestStart":159.39999985694885,"responseEnd":311.09999990463257,"responseStart":311.09999990463257,"secureConnectionStart":159.39999985694885},{"duration":415.09999990463257,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-js/jira.webresources:bigpipe-js.js","startTime":171.70000004768372,"connectEnd":171.70000004768372,"connectStart":171.70000004768372,"domainLookupEnd":171.70000004768372,"domainLookupStart":171.70000004768372,"fetchStart":171.70000004768372,"redirectEnd":0,"redirectStart":0,"requestStart":171.70000004768372,"responseEnd":586.7999999523163,"responseStart":586.7999999523163,"secureConnectionStart":171.70000004768372},{"duration":407.40000009536743,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-init/jira.webresources:bigpipe-init.js","startTime":182.09999990463257,"connectEnd":182.09999990463257,"connectStart":182.09999990463257,"domainLookupEnd":182.09999990463257,"domainLookupStart":182.09999990463257,"fetchStart":182.09999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":182.09999990463257,"responseEnd":589.5,"responseStart":589.5,"secureConnectionStart":182.09999990463257},{"duration":200.40000009536743,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":374.59999990463257,"connectEnd":374.59999990463257,"connectStart":374.59999990463257,"domainLookupEnd":374.59999990463257,"domainLookupStart":374.59999990463257,"fetchStart":374.59999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":374.59999990463257,"responseEnd":575,"responseStart":575,"secureConnectionStart":374.59999990463257},{"duration":2.0999999046325684,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":606.2000000476837,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":606.2000000476837,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":608.2999999523163,"responseStart":0,"secureConnectionStart":0},{"duration":3.4000000953674316,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/e65b778d185daf5aee24936755b43da6/_/download/contextbatch/js/browser-metrics-plugin.contrib,-_super,-project.issue.navigator,-jira.view.issue,-atl.general/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true","startTime":629.0999999046326,"connectEnd":629.0999999046326,"connectStart":629.0999999046326,"domainLookupEnd":629.0999999046326,"domainLookupStart":629.0999999046326,"fetchStart":629.0999999046326,"redirectEnd":0,"redirectStart":0,"requestStart":629.0999999046326,"responseEnd":632.5,"responseStart":632.5,"secureConnectionStart":629.0999999046326}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":16,"responseStart":154,"responseEnd":182,"domLoading":157,"domInteractive":811,"domContentLoadedEventStart":811,"domContentLoadedEventEnd":857,"domComplete":966,"loadEventStart":966,"loadEventEnd":966,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":786.8999998569489},{"name":"bigPipe.sidebar-id.end","time":787.5999999046326},{"name":"bigPipe.activity-panel-pipe-id.start","time":787.7999999523163},{"name":"bigPipe.activity-panel-pipe-id.end","time":788.5999999046326},{"name":"activityTabFullyLoaded","time":873.3999998569489}],"measures":[],"correlationId":"d73d70f2a0448","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":74,"dbReadsTimeInMs":11,"dbConnsTimeInMs":18,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}