The major cases for the --check-if-upgrade-is-needed are:
MDEV-27606 - debian upgrades, which for historical reasons ran mysql_upgrade to expose new functionality to the user.
MDEV-25670 Docker Library should run mariadb_upgrade - a very requested user feature that cannot be achieved in all the normal ways of container interaction.
Because of the current implementation the current Debian implementation would look like:
Start a temporary server in all the fancy ways to prevent user access, plugin initialization, excessive startup time etc (MDEV-27606 has a more complete list)
Run mysql_upgrade --check-if-upgrade-is-needed
If this returns true, probably not as already upgrade, run mysql_upgrade --upgrade-system-tables
shutdown temporary server
start real server with configured options
The container implementation would be largely the same.
(mariadb server is offline as starting point by default)
Run mysql_upgrade --check-if-upgrade-is-needed
if true; start temporary server; run mysql_upgrade; shutdown temporary server
start real server with configured options
The reasons for the mysql_upgrade to connect to the server are:
to SELECT VERSION
to obtain the datadir where mysql_upgrade_info can be examined
To obtain these for the purposes of mysql_upgrade --check-if-upgrade-is-needed without connecting to the server:
mysql_upgrade has a hard baked server version
datadir can be a mysql_upgrade option
While there is no 100% certainty that the mysql_upgrade version is the same as the mariadbd server version when connected, it always will be in the container (one version per container) and most likely in the Debian installation. Miss-use of mysql_upgrade from different server versions at the check stage can rely on the real upgrade version check to be more thorough.
Even if the --check-if-upgrade-is-need from a 10.2 is run and returns a incorrect result because the server version is 10.1, the version of the server is still checked with the mysql_upgrade is properly run (unless --skip-force is specified).
So lets re-implement mysql_upgrade --check-if-upgrade-is-needed to have a datadir option and run in an offline mode. This will prevent two mariadb server starts on every time systemd/sysv init/container entrypoint starts and account for the common of an upgrade already occurred, knowing there's a small chance of incorrect versions mismatch, and knowing the fall back version check is there.
While this doesn't strictly block MDEV-27606 or MDEV-25670 as the first double start mechanism is implemented, many users will complain if the Debian packaging/container entry-point is implemented the current way.
Attachments
Issue Links
is caused by
MDEV-27279mariadb_upgrade add --check-if-upgrade-is-needed / restrict tests to major version
Closed
is part of
MDEV-27606change debian packaging to not run mariadb-upgrade at the same time as anything
Note: 1 is necessary because mysql_upgrade needs to connect to the server and should no try to access the upgrade_info directly.
The reasons are:
mysql_upgrade needs to verify the following version information
mysql_upgrade version (from compile time)
Version in the mysql_upgrade_info file
Version of the installed (running) server: All version info are needed to know if there is a need to do an upgrade and if the upgrade can be done.
mysql_upgrade also need to know that the mysql_upgrade info it access/creates is for the running server.
The safest way to do that (which will work for any use case) is to get the datadir from the server.
Another option would be to add an option --datadir to mysql_upgrade, but this is less safe as there are several ways this can go wrong:
The datadir could point to another directory than the running databases directory, in which case the upgrade will probably never be done (if this is done in a script).
One could add the mysql_update --datadir option to a global config file. In this case any local users installation of MariaDB would be affected and if they run 'mysql_upgrade' it would use the global installation and probably not do anything even if a local upgrade is needed.
I totally agree with the above, the actions of mysql_upgrade when its actually doing the upgrade need to do all the strict version/datadir checks. Just not with --check-if-upgrade-is-needed as a quick check which will almost never encounter these problems, and even if it did, it would be the responsibly of actually doing the upgrade to check it strictly.
Daniel Black
added a comment - Note: 1 is necessary because mysql_upgrade needs to connect to the server and should no try to access the upgrade_info directly.
The reasons are:
mysql_upgrade needs to verify the following version information
mysql_upgrade version (from compile time)
Version in the mysql_upgrade_info file
Version of the installed (running) server: All version info are needed to know if there is a need to do an upgrade and if the upgrade can be done.
mysql_upgrade also need to know that the mysql_upgrade info it access/creates is for the running server.
The safest way to do that (which will work for any use case) is to get the datadir from the server.
Another option would be to add an option --datadir to mysql_upgrade, but this is less safe as there are several ways this can go wrong:
The datadir could point to another directory than the running databases directory, in which case the upgrade will probably never be done (if this is done in a script).
One could add the mysql_update --datadir option to a global config file. In this case any local users installation of MariaDB would be affected and if they run 'mysql_upgrade' it would use the global installation and probably not do anything even if a local upgrade is needed.
I totally agree with the above, the actions of mysql_upgrade when its actually doing the upgrade need to do all the strict version/datadir checks. Just not with --check-if-upgrade-is-needed as a quick check which will almost never encounter these problems, and even if it did, it would be the responsibly of actually doing the upgrade to check it strictly.
People
Daniel Black
Daniel Black
Votes:
0Vote for this issue
Watchers:
5Start watching this issue
Dates
Created:
Updated:
Git Integration
Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.
{"report":{"fcp":761.5,"ttfb":226.19999980926514,"pageVisibility":"visible","entityId":107302,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":1,"journeyId":"c729457c-8c4d-4efd-bce0-c74523a70799","navigationType":0,"readyForUser":823.3000001907349,"redirectCount":0,"resourceLoadedEnd":441.5,"resourceLoadedStart":233.80000019073486,"resourceTiming":[{"duration":6.099999904632568,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":233.80000019073486,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":233.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":239.90000009536743,"responseStart":0,"secureConnectionStart":0},{"duration":6.800000190734863,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2cib/820016/12ta74/494e4c556ecbb29f90a3d3b4f09cb99c/_/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&whisper-enabled=true","startTime":234,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":234,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":240.80000019073486,"responseStart":0,"secureConnectionStart":0},{"duration":75.7000002861023,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":234.19999980926514,"connectEnd":234.19999980926514,"connectStart":234.19999980926514,"domainLookupEnd":234.19999980926514,"domainLookupStart":234.19999980926514,"fetchStart":234.19999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":243.80000019073486,"responseEnd":309.90000009536743,"responseStart":264.40000009536743,"secureConnectionStart":234.19999980926514},{"duration":92.59999990463257,"initiatorType":"script","name":"https://jira.mariadb.org/s/2d8175ec2fa4c816e8023260bd8c1786-CDN/lu2cib/820016/12ta74/494e4c556ecbb29f90a3d3b4f09cb99c/_/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&whisper-enabled=true","startTime":234.40000009536743,"connectEnd":234.40000009536743,"connectStart":234.40000009536743,"domainLookupEnd":234.40000009536743,"domainLookupStart":234.40000009536743,"fetchStart":234.40000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":244.90000009536743,"responseEnd":327,"responseStart":278.80000019073486,"secureConnectionStart":234.40000009536743},{"duration":40.59999990463257,"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":234.59999990463257,"connectEnd":234.59999990463257,"connectStart":234.59999990463257,"domainLookupEnd":234.59999990463257,"domainLookupStart":234.59999990463257,"fetchStart":234.59999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":246.19999980926514,"responseEnd":275.19999980926514,"responseStart":274.5,"secureConnectionStart":234.59999990463257},{"duration":45.69999980926514,"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":234.80000019073486,"connectEnd":234.80000019073486,"connectStart":234.80000019073486,"domainLookupEnd":234.80000019073486,"domainLookupStart":234.80000019073486,"fetchStart":234.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":246.80000019073486,"responseEnd":280.5,"responseStart":279.69999980926514,"secureConnectionStart":234.80000019073486},{"duration":46.30000019073486,"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":235,"connectEnd":235,"connectStart":235,"domainLookupEnd":235,"domainLookupStart":235,"fetchStart":235,"redirectEnd":0,"redirectStart":0,"requestStart":248.5,"responseEnd":281.30000019073486,"responseStart":280.5,"secureConnectionStart":235},{"duration":13.900000095367432,"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":235.19999980926514,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":235.19999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":249.09999990463257,"responseStart":0,"secureConnectionStart":0},{"duration":52.19999980926514,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":235.30000019073486,"connectEnd":235.30000019073486,"connectStart":235.30000019073486,"domainLookupEnd":235.30000019073486,"domainLookupStart":235.30000019073486,"fetchStart":235.30000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":252.5,"responseEnd":287.5,"responseStart":286.69999980926514,"secureConnectionStart":235.30000019073486},{"duration":13.599999904632568,"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":235.59999990463257,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":235.59999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":249.19999980926514,"responseStart":0,"secureConnectionStart":0},{"duration":53.799999713897705,"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":235.80000019073486,"connectEnd":235.80000019073486,"connectStart":235.80000019073486,"domainLookupEnd":235.80000019073486,"domainLookupStart":235.80000019073486,"fetchStart":235.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":253.80000019073486,"responseEnd":289.59999990463257,"responseStart":287.59999990463257,"secureConnectionStart":235.80000019073486},{"duration":42.5,"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":248.69999980926514,"connectEnd":275.40000009536743,"connectStart":275.40000009536743,"domainLookupEnd":275.40000009536743,"domainLookupStart":275.40000009536743,"fetchStart":248.69999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":276.19999980926514,"responseEnd":291.19999980926514,"responseStart":289.90000009536743,"secureConnectionStart":275.40000009536743},{"duration":192,"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":249.5,"connectEnd":249.5,"connectStart":249.5,"domainLookupEnd":249.5,"domainLookupStart":249.5,"fetchStart":249.5,"redirectEnd":0,"redirectStart":0,"requestStart":291.40000009536743,"responseEnd":441.5,"responseStart":439.40000009536743,"secureConnectionStart":249.5},{"duration":177,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":517.5,"connectEnd":517.5,"connectStart":517.5,"domainLookupEnd":517.5,"domainLookupStart":517.5,"fetchStart":517.5,"redirectEnd":0,"redirectStart":0,"requestStart":652.6999998092651,"responseEnd":694.5,"responseStart":693.5,"secureConnectionStart":517.5},{"duration":124,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":734,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":734,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":858,"responseStart":0,"secureConnectionStart":0},{"duration":106.2000002861023,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":753.0999999046326,"connectEnd":753.0999999046326,"connectStart":753.0999999046326,"domainLookupEnd":753.0999999046326,"domainLookupStart":753.0999999046326,"fetchStart":753.0999999046326,"redirectEnd":0,"redirectStart":0,"requestStart":818.5,"responseEnd":859.3000001907349,"responseStart":857.9000000953674,"secureConnectionStart":753.0999999046326}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":42,"responseStart":227,"responseEnd":249,"domLoading":230,"domInteractive":884,"domContentLoadedEventStart":884,"domContentLoadedEventEnd":921,"domComplete":1079,"loadEventStart":1079,"loadEventEnd":1079,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":860.1999998092651},{"name":"bigPipe.sidebar-id.end","time":861},{"name":"bigPipe.activity-panel-pipe-id.start","time":861.1999998092651},{"name":"bigPipe.activity-panel-pipe-id.end","time":862},{"name":"activityTabFullyLoaded","time":938.3000001907349}],"measures":[],"correlationId":"e1309e8d3cfac2","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":113,"dbReadsTimeInMs":16,"dbConnsTimeInMs":25,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
I totally agree with the above, the actions of mysql_upgrade when its actually doing the upgrade need to do all the strict version/datadir checks. Just not with --check-if-upgrade-is-needed as a quick check which will almost never encounter these problems, and even if it did, it would be the responsibly of actually doing the upgrade to check it strictly.