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
|
Transition |
Time In Source Status |
Execution Times |
Open |
|
Confirmed |
|
11d 3h 18m
|
1
|
Confirmed |
|
Closed |
|
29d 15h 14m
|
1
|
{"report":{"fcp":880.7999992370605,"ttfb":213.69999980926514,"pageVisibility":"visible","entityId":62162,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":32,"apdex":1,"journeyId":"057c5229-4416-42b7-80e5-79034fec5b89","navigationType":0,"readyForUser":993.5999994277954,"redirectCount":0,"resourceLoadedEnd":1108.6999998092651,"resourceLoadedStart":219.5999994277954,"resourceTiming":[{"duration":173.9000005722046,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":219.5999994277954,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":219.5999994277954,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":393.5,"responseStart":0,"secureConnectionStart":0},{"duration":174,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2cib/820016/12ta74/2bf333562ca6724060a9d5f1535471f6/_/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":219.79999923706055,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":219.79999923706055,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":393.79999923706055,"responseStart":0,"secureConnectionStart":0},{"duration":192,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":220.0999994277954,"connectEnd":220.0999994277954,"connectStart":220.0999994277954,"domainLookupEnd":220.0999994277954,"domainLookupStart":220.0999994277954,"fetchStart":220.0999994277954,"redirectEnd":0,"redirectStart":0,"requestStart":220.0999994277954,"responseEnd":412.0999994277954,"responseStart":412.0999994277954,"secureConnectionStart":220.0999994277954},{"duration":289.69999980926514,"initiatorType":"script","name":"https://jira.mariadb.org/s/2d8175ec2fa4c816e8023260bd8c1786-CDN/lu2cib/820016/12ta74/2bf333562ca6724060a9d5f1535471f6/_/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":220.19999980926514,"connectEnd":220.19999980926514,"connectStart":220.19999980926514,"domainLookupEnd":220.19999980926514,"domainLookupStart":220.19999980926514,"fetchStart":220.19999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":220.19999980926514,"responseEnd":509.8999996185303,"responseStart":509.8999996185303,"secureConnectionStart":220.19999980926514},{"duration":293.0999994277954,"initiatorType":"script","name":"https://jira.mariadb.org/s/a9324d6758d385eb45c462685ad88f1d-CDN/lu2cib/820016/12ta74/c92c0caa9a024ae85b0ebdbed7fb4bd7/_/download/contextbatch/js/atl.global,-_super/batch.js?locale=en","startTime":220.5,"connectEnd":220.5,"connectStart":220.5,"domainLookupEnd":220.5,"domainLookupStart":220.5,"fetchStart":220.5,"redirectEnd":0,"redirectStart":0,"requestStart":220.5,"responseEnd":513.5999994277954,"responseStart":513.5999994277954,"secureConnectionStart":220.5},{"duration":293.5,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-en/jira.webresources:calendar-en.js","startTime":220.5999994277954,"connectEnd":220.5999994277954,"connectStart":220.5999994277954,"domainLookupEnd":220.5999994277954,"domainLookupStart":220.5999994277954,"fetchStart":220.5999994277954,"redirectEnd":0,"redirectStart":0,"requestStart":220.5999994277954,"responseEnd":514.0999994277954,"responseStart":514.0999994277954,"secureConnectionStart":220.5999994277954},{"duration":293.6000003814697,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-localisation-moment/jira.webresources:calendar-localisation-moment.js","startTime":220.79999923706055,"connectEnd":220.79999923706055,"connectStart":220.79999923706055,"domainLookupEnd":220.79999923706055,"domainLookupStart":220.79999923706055,"fetchStart":220.79999923706055,"redirectEnd":0,"redirectStart":0,"requestStart":220.79999923706055,"responseEnd":514.3999996185303,"responseStart":514.3999996185303,"secureConnectionStart":220.79999923706055},{"duration":336.5,"initiatorType":"link","name":"https://jira.mariadb.org/s/b04b06a02d1959df322d9cded3aeecc1-CDN/lu2cib/820016/12ta74/a2ff6aa845ffc9a1d22fe23d9ee791fc/_/download/contextbatch/css/jira.global.look-and-feel,-_super/batch.css","startTime":221,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":221,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":557.5,"responseStart":0,"secureConnectionStart":0},{"duration":293.69999980926514,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":221.0999994277954,"connectEnd":221.0999994277954,"connectStart":221.0999994277954,"domainLookupEnd":221.0999994277954,"domainLookupStart":221.0999994277954,"fetchStart":221.0999994277954,"redirectEnd":0,"redirectStart":0,"requestStart":221.0999994277954,"responseEnd":514.7999992370605,"responseStart":514.7999992370605,"secureConnectionStart":221.0999994277954},{"duration":336.30000019073486,"initiatorType":"link","name":"https://jira.mariadb.org/s/3ac36323ba5e4eb0af2aa7ac7211b4bb-CDN/lu2cib/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":221.29999923706055,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":221.29999923706055,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":557.5999994277954,"responseStart":0,"secureConnectionStart":0},{"duration":293.8999996185303,"initiatorType":"script","name":"https://jira.mariadb.org/s/5d5e8fe91fbc506585e83ea3b62ccc4b-CDN/lu2cib/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":221.39999961853027,"connectEnd":221.39999961853027,"connectStart":221.39999961853027,"domainLookupEnd":221.39999961853027,"domainLookupStart":221.39999961853027,"fetchStart":221.39999961853027,"redirectEnd":0,"redirectStart":0,"requestStart":221.39999961853027,"responseEnd":515.2999992370605,"responseStart":515.2999992370605,"secureConnectionStart":221.39999961853027},{"duration":801.3999996185303,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-js/jira.webresources:bigpipe-js.js","startTime":226.5,"connectEnd":226.5,"connectStart":226.5,"domainLookupEnd":226.5,"domainLookupStart":226.5,"fetchStart":226.5,"redirectEnd":0,"redirectStart":0,"requestStart":226.5,"responseEnd":1027.8999996185303,"responseStart":1027.8999996185303,"secureConnectionStart":226.5},{"duration":882.1000003814697,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-init/jira.webresources:bigpipe-init.js","startTime":226.5999994277954,"connectEnd":226.5999994277954,"connectStart":226.5999994277954,"domainLookupEnd":226.5999994277954,"domainLookupStart":226.5999994277954,"fetchStart":226.5999994277954,"redirectEnd":0,"redirectStart":0,"requestStart":226.5999994277954,"responseEnd":1108.6999998092651,"responseStart":1108.6999998092651,"secureConnectionStart":226.5999994277954},{"duration":458.5,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":569.7999992370605,"connectEnd":569.7999992370605,"connectStart":569.7999992370605,"domainLookupEnd":569.7999992370605,"domainLookupStart":569.7999992370605,"fetchStart":569.7999992370605,"redirectEnd":0,"redirectStart":0,"requestStart":569.7999992370605,"responseEnd":1028.2999992370605,"responseStart":1028.2999992370605,"secureConnectionStart":569.7999992370605},{"duration":235.80000019073486,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":874.0999994277954,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":874.0999994277954,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1109.8999996185303,"responseStart":0,"secureConnectionStart":0}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":18,"responseStart":213,"responseEnd":218,"domLoading":217,"domInteractive":1188,"domContentLoadedEventStart":1188,"domContentLoadedEventEnd":1241,"domComplete":1506,"loadEventStart":1506,"loadEventEnd":1507,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1168.6999998092651},{"name":"bigPipe.sidebar-id.end","time":1169.5},{"name":"bigPipe.activity-panel-pipe-id.start","time":1169.6999998092651},{"name":"bigPipe.activity-panel-pipe-id.end","time":1170.5999994277954},{"name":"activityTabFullyLoaded","time":1255.0999994277954}],"measures":[],"correlationId":"57f9b9dc4676b9","effectiveType":"4g","downlink":9.3,"rtt":0,"serverDuration":119,"dbReadsTimeInMs":20,"dbConnsTimeInMs":30,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}