While investigating database errors logged in my application, I noticed that some records that reference a different table with an ON DELETE CASCADE constraint had not been deleted. This constraint normally works, this is the first time I've spotted stale rows.
The queries below show stale rows in matchmaking_group_users and matchmaking_group_maps. They both have a matchmaking_group_id that references the column id in the table matchmaking_groups.
MariaDB [esportal]> select * from matchmaking_group_users where matchmaking_group_id not in (select id from matchmaking_groups);
|
+----------------------+-----------+------------+
|
| matchmaking_group_id | user_id | microphone |
|
+----------------------+-----------+------------+
|
| 278066 | 182715729 | 1 |
|
+----------------------+-----------+------------+
|
1 row in set (0.00 sec)
|
|
MariaDB [esportal]> select * from matchmaking_group_maps where matchmaking_group_id not in (select id from matchmaking_groups);
|
+----------------------+--------+----------+
|
| matchmaking_group_id | map_id | priority |
|
+----------------------+--------+----------+
|
| 278066 | 1 | 4 |
|
| 278066 | 2 | 2 |
|
| 278066 | 5 | 1 |
|
| 278066 | 6 | 3 |
|
| 278066 | 7 | 6 |
|
| 278066 | 8 | 5 |
|
+----------------------+--------+----------+
|
6 rows in set (0.00 sec)
|
|
MariaDB [esportal]> show create table matchmaking_group_users;
|
+-------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
| Table | Create Table |
|
+-------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
| matchmaking_group_users | CREATE TABLE `matchmaking_group_users` (
|
`matchmaking_group_id` bigint(20) unsigned NOT NULL,
|
`user_id` int(10) unsigned NOT NULL,
|
`microphone` tinyint(1) unsigned NOT NULL,
|
PRIMARY KEY (`matchmaking_group_id`,`user_id`),
|
UNIQUE KEY `user_id` (`user_id`),
|
CONSTRAINT `matchmaking_group_users_ibfk_1` FOREIGN KEY (`matchmaking_group_id`) REFERENCES `matchmaking_groups` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
CONSTRAINT `matchmaking_group_users_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 |
|
+-------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
1 row in set (0.00 sec)
|
|
MariaDB [esportal]> show create table matchmaking_group_maps;
|
+------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
| Table | Create Table |
|
+------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
| matchmaking_group_maps | CREATE TABLE `matchmaking_group_maps` (
|
`matchmaking_group_id` bigint(20) unsigned NOT NULL,
|
`map_id` tinyint(2) unsigned NOT NULL,
|
`priority` tinyint(2) unsigned NOT NULL,
|
PRIMARY KEY (`matchmaking_group_id`,`map_id`),
|
CONSTRAINT `matchmaking_group_maps_ibfk_1` FOREIGN KEY (`matchmaking_group_id`) REFERENCES `matchmaking_groups` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 |
|
+------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
1 row in set (0.00 sec)
|
I'm running the latest stable version on Debian Stretch:
I did spot these errors in /var/log/daemon.log, but I'm not sure if they're relevant.
Jul 3 22:04:58 esportal mysqld[1772]: 2017-07-03 22:04:58 140365854455552 [ERROR] InnoDB: WSREP: referenced FK check fail: 15 index user_id table esportal/match_rematch_votes
|
Jul 4 17:40:59 esportal mysqld[1772]: 2017-07-04 17:40:59 140365548082944 [ERROR] InnoDB: WSREP: referenced FK check fail: 15 index host_user_id table esportal/matchmaking_groups
|
{"report":{"fcp":923.5,"ttfb":188.20000004768372,"pageVisibility":"visible","entityId":62162,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"23ee4ec2-01d4-4c96-9893-aeb491ad3833","navigationType":0,"readyForUser":1028.7000000476837,"redirectCount":0,"resourceLoadedEnd":1082.3999999761581,"resourceLoadedStart":194.70000004768372,"resourceTiming":[{"duration":209.5,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":194.70000004768372,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":194.70000004768372,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":404.2000000476837,"responseStart":0,"secureConnectionStart":0},{"duration":209.20000004768372,"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":195,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":195,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":404.2000000476837,"responseStart":0,"secureConnectionStart":0},{"duration":218.89999997615814,"initiatorType":"script","name":"https://jira.mariadb.org/s/fbf975c0cce4b1abf04784eeae9ba1f4-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":195,"connectEnd":195,"connectStart":195,"domainLookupEnd":195,"domainLookupStart":195,"fetchStart":195,"redirectEnd":0,"redirectStart":0,"requestStart":195,"responseEnd":413.89999997615814,"responseStart":413.89999997615814,"secureConnectionStart":195},{"duration":348.10000002384186,"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":195.20000004768372,"connectEnd":195.20000004768372,"connectStart":195.20000004768372,"domainLookupEnd":195.20000004768372,"domainLookupStart":195.20000004768372,"fetchStart":195.20000004768372,"redirectEnd":0,"redirectStart":0,"requestStart":195.20000004768372,"responseEnd":543.3000000715256,"responseStart":543.3000000715256,"secureConnectionStart":195.20000004768372},{"duration":352.10000002384186,"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":195.39999997615814,"connectEnd":195.39999997615814,"connectStart":195.39999997615814,"domainLookupEnd":195.39999997615814,"domainLookupStart":195.39999997615814,"fetchStart":195.39999997615814,"redirectEnd":0,"redirectStart":0,"requestStart":195.39999997615814,"responseEnd":547.5,"responseStart":547.5,"secureConnectionStart":195.39999997615814},{"duration":352.5,"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":195.5,"connectEnd":195.5,"connectStart":195.5,"domainLookupEnd":195.5,"domainLookupStart":195.5,"fetchStart":195.5,"redirectEnd":0,"redirectStart":0,"requestStart":195.5,"responseEnd":548,"responseStart":548,"secureConnectionStart":195.5},{"duration":352.7000000476837,"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":195.60000002384186,"connectEnd":195.60000002384186,"connectStart":195.60000002384186,"domainLookupEnd":195.60000002384186,"domainLookupStart":195.60000002384186,"fetchStart":195.60000002384186,"redirectEnd":0,"redirectStart":0,"requestStart":195.60000002384186,"responseEnd":548.3000000715256,"responseStart":548.3000000715256,"secureConnectionStart":195.60000002384186},{"duration":353.2999999523163,"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":195.80000007152557,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":195.80000007152557,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":549.1000000238419,"responseStart":0,"secureConnectionStart":0},{"duration":352.89999997615814,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":195.80000007152557,"connectEnd":195.80000007152557,"connectStart":195.80000007152557,"domainLookupEnd":195.80000007152557,"domainLookupStart":195.80000007152557,"fetchStart":195.80000007152557,"redirectEnd":0,"redirectStart":0,"requestStart":195.80000007152557,"responseEnd":548.7000000476837,"responseStart":548.7000000476837,"secureConnectionStart":195.80000007152557},{"duration":353.40000009536743,"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":195.89999997615814,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":195.89999997615814,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":549.3000000715256,"responseStart":0,"secureConnectionStart":0},{"duration":353.2000000476837,"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":196.10000002384186,"connectEnd":196.10000002384186,"connectStart":196.10000002384186,"domainLookupEnd":196.10000002384186,"domainLookupStart":196.10000002384186,"fetchStart":196.10000002384186,"redirectEnd":0,"redirectStart":0,"requestStart":196.10000002384186,"responseEnd":549.3000000715256,"responseStart":549.3000000715256,"secureConnectionStart":196.10000002384186},{"duration":478.10000002384186,"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":197,"connectEnd":197,"connectStart":197,"domainLookupEnd":197,"domainLookupStart":197,"fetchStart":197,"redirectEnd":0,"redirectStart":0,"requestStart":197,"responseEnd":675.1000000238419,"responseStart":675.1000000238419,"secureConnectionStart":197},{"duration":860.7000000476837,"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":201.60000002384186,"connectEnd":201.60000002384186,"connectStart":201.60000002384186,"domainLookupEnd":201.60000002384186,"domainLookupStart":201.60000002384186,"fetchStart":201.60000002384186,"redirectEnd":0,"redirectStart":0,"requestStart":201.60000002384186,"responseEnd":1062.3000000715256,"responseStart":1062.3000000715256,"secureConnectionStart":201.60000002384186},{"duration":105.60000002384186,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":570.7000000476837,"connectEnd":570.7000000476837,"connectStart":570.7000000476837,"domainLookupEnd":570.7000000476837,"domainLookupStart":570.7000000476837,"fetchStart":570.7000000476837,"redirectEnd":0,"redirectStart":0,"requestStart":570.7000000476837,"responseEnd":676.3000000715256,"responseStart":676.3000000715256,"secureConnectionStart":570.7000000476837},{"duration":245.79999995231628,"initiatorType":"link","name":"https://jira.mariadb.org/s/d5715adaadd168a9002b108b2b039b50-CDN/lu2bu7/820016/12ta74/be4b45e9cec53099498fa61c8b7acba4/_/download/contextbatch/css/jira.project.sidebar,-_super,-project.issue.navigator,-jira.general,-jira.browse.project,-jira.view.issue,-jira.global,-atl.general,-com.atlassian.jira.projects.sidebar.init/batch.css?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true","startTime":836.6000000238419,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":836.6000000238419,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1082.3999999761581,"responseStart":0,"secureConnectionStart":0},{"duration":284.39999997615814,"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":837.5,"connectEnd":837.5,"connectStart":837.5,"domainLookupEnd":837.5,"domainLookupStart":837.5,"fetchStart":837.5,"redirectEnd":0,"redirectStart":0,"requestStart":837.5,"responseEnd":1121.8999999761581,"responseStart":1121.8999999761581,"secureConnectionStart":837.5},{"duration":291,"initiatorType":"script","name":"https://jira.mariadb.org/s/f51ef5507eea4c158f257c66c93b2a3f-CDN/lu2bu7/820016/12ta74/be4b45e9cec53099498fa61c8b7acba4/_/download/contextbatch/js/jira.project.sidebar,-_super,-project.issue.navigator,-jira.general,-jira.browse.project,-jira.view.issue,-jira.global,-atl.general,-com.atlassian.jira.projects.sidebar.init/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&locale=en&slack-enabled=true","startTime":837.8000000715256,"connectEnd":837.8000000715256,"connectStart":837.8000000715256,"domainLookupEnd":837.8000000715256,"domainLookupStart":837.8000000715256,"fetchStart":837.8000000715256,"redirectEnd":0,"redirectStart":0,"requestStart":837.8000000715256,"responseEnd":1128.8000000715256,"responseStart":1128.8000000715256,"secureConnectionStart":837.8000000715256}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":28,"responseStart":187,"responseEnd":192,"domLoading":191,"domInteractive":1100,"domContentLoadedEventStart":1100,"domContentLoadedEventEnd":1161,"domComplete":1972,"loadEventStart":1972,"loadEventEnd":1973,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1078.8000000715256},{"name":"bigPipe.sidebar-id.end","time":1079.6000000238419},{"name":"bigPipe.activity-panel-pipe-id.start","time":1079.8000000715256},{"name":"bigPipe.activity-panel-pipe-id.end","time":1082.3999999761581},{"name":"activityTabFullyLoaded","time":1174.8999999761581}],"measures":[],"correlationId":"e3d9cfc852dbec","effectiveType":"4g","downlink":9.8,"rtt":0,"serverDuration":83,"dbReadsTimeInMs":13,"dbConnsTimeInMs":21,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}