Let's try to simulate behavior
MariaDB [d]> CREATE SEQUENCE a1 START WITH 5000 INCREMENT BY 1 MINVALUE=5000 MAXVALUE=5003;
|
Query OK, 0 rows affected (0.026 sec)
|
|
MariaDB [d]> SELECT LASTVAL(a1), NEXTVAL(a1);
|
+-------------+-------------+
|
| LASTVAL(a1) | NEXTVAL(a1) |
|
+-------------+-------------+
|
| NULL | 5000 |
|
+-------------+-------------+
|
1 row in set (0.001 sec)
|
|
MariaDB [d]> SELECT LASTVAL(a1), NEXTVAL(a1);
|
+-------------+-------------+
|
| LASTVAL(a1) | NEXTVAL(a1) |
|
+-------------+-------------+
|
| 5000 | 5001 |
|
+-------------+-------------+
|
1 row in set (0.000 sec)
|
|
MariaDB [d]> FLUSH TABLES;
|
Query OK, 0 rows affected (0.000 sec)
|
|
MariaDB [d]> SELECT LASTVAL(a1); # FLUSH TABLES shouldn't affect LASTVAL() - OK
|
+-------------+
|
| LASTVAL(a1) |
|
+-------------+
|
| 5001 |
|
+-------------+
|
1 row in set (0.001 sec)
|
|
MariaDB [d]> SELECT NEXTVAL(a1); # Problematic behavior
|
ERROR 4084 (HY000): Sequence 'd.a1' has run out
|
MariaDB [d]> SELECT LASTVAL(a1); # NEXTVAL() affects LASTVAL(), should it?
|
+-------------+
|
| LASTVAL(a1) |
|
+-------------+
|
| NULL |
|
+-------------+
|
1 row in set (0.000 sec)
|
|
The same as above happens if we start the new session or restart the server.
So here 2 questions should be addressed:
1. How to open/count table/value of closed sequence, after FLUSH TABLES is invoked? Documentation nextval sequence should be updated.
Also, the error message ERROR 4084 (HY000): Sequence 'd.a1' has run out is the same for "empty" sequence (no cached value) as showed above as well as for NON-CYCLE sequence crossing MAXVALUE. Distinction between those should be done.
2. LASTVAL in the current situation (crossing MAXVALUE) is correct? If yes it should be documented saying that crossing the value for NEXTVAL is setting the function to NULL. If not, let's change it.
Transition |
Time In Source Status |
Execution Times |
Open |
|
Closed |
|
1332d 1h 4m
|
1
|
{"report":{"fcp":900.3999999761581,"ttfb":225.59999999403954,"pageVisibility":"visible","entityId":92145,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":1,"journeyId":"2343572c-b105-49c0-816b-64158d334afd","navigationType":0,"readyForUser":975.2999999821186,"redirectCount":0,"resourceLoadedEnd":894.8999999761581,"resourceLoadedStart":230.89999997615814,"resourceTiming":[{"duration":177.5,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bv2/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":230.89999997615814,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":230.89999997615814,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":408.39999997615814,"responseStart":0,"secureConnectionStart":0},{"duration":177.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":231.19999998807907,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":231.19999998807907,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":408.69999998807907,"responseStart":0,"secureConnectionStart":0},{"duration":185.59999999403954,"initiatorType":"script","name":"https://jira.mariadb.org/s/e9b27a47da5fb0f74a35acd57e9847fb-CDN/lu2bv2/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":231.2999999821186,"connectEnd":231.2999999821186,"connectStart":231.2999999821186,"domainLookupEnd":231.2999999821186,"domainLookupStart":231.2999999821186,"fetchStart":231.2999999821186,"redirectEnd":0,"redirectStart":0,"requestStart":231.2999999821186,"responseEnd":416.89999997615814,"responseStart":416.89999997615814,"secureConnectionStart":231.2999999821186},{"duration":255.09999999403954,"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":231.5,"connectEnd":231.5,"connectStart":231.5,"domainLookupEnd":231.5,"domainLookupStart":231.5,"fetchStart":231.5,"redirectEnd":0,"redirectStart":0,"requestStart":231.5,"responseEnd":486.59999999403954,"responseStart":486.59999999403954,"secureConnectionStart":231.5},{"duration":258.09999999403954,"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":231.69999998807907,"connectEnd":231.69999998807907,"connectStart":231.69999998807907,"domainLookupEnd":231.69999998807907,"domainLookupStart":231.69999998807907,"fetchStart":231.69999998807907,"redirectEnd":0,"redirectStart":0,"requestStart":231.69999998807907,"responseEnd":489.7999999821186,"responseStart":489.7999999821186,"secureConnectionStart":231.69999998807907},{"duration":258.40000000596046,"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":231.89999997615814,"connectEnd":231.89999997615814,"connectStart":231.89999997615814,"domainLookupEnd":231.89999997615814,"domainLookupStart":231.89999997615814,"fetchStart":231.89999997615814,"redirectEnd":0,"redirectStart":0,"requestStart":231.89999997615814,"responseEnd":490.2999999821186,"responseStart":490.2999999821186,"secureConnectionStart":231.89999997615814},{"duration":258.69999998807907,"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":232.09999999403954,"connectEnd":232.09999999403954,"connectStart":232.09999999403954,"domainLookupEnd":232.09999999403954,"domainLookupStart":232.09999999403954,"fetchStart":232.09999999403954,"redirectEnd":0,"redirectStart":0,"requestStart":232.09999999403954,"responseEnd":490.7999999821186,"responseStart":490.7999999821186,"secureConnectionStart":232.09999999403954},{"duration":319.69999998807907,"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":232.19999998807907,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":232.19999998807907,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":551.8999999761581,"responseStart":0,"secureConnectionStart":0},{"duration":259,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":232.2999999821186,"connectEnd":232.2999999821186,"connectStart":232.2999999821186,"domainLookupEnd":232.2999999821186,"domainLookupStart":232.2999999821186,"fetchStart":232.2999999821186,"redirectEnd":0,"redirectStart":0,"requestStart":232.2999999821186,"responseEnd":491.2999999821186,"responseStart":491.2999999821186,"secureConnectionStart":232.2999999821186},{"duration":319.59999999403954,"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":232.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":232.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":552.0999999940395,"responseStart":0,"secureConnectionStart":0},{"duration":259.09999999403954,"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":232.69999998807907,"connectEnd":232.69999998807907,"connectStart":232.69999998807907,"domainLookupEnd":232.69999998807907,"domainLookupStart":232.69999998807907,"fetchStart":232.69999998807907,"redirectEnd":0,"redirectStart":0,"requestStart":232.69999998807907,"responseEnd":491.7999999821186,"responseStart":491.7999999821186,"secureConnectionStart":232.69999998807907},{"duration":625.2999999821186,"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":233.5,"connectEnd":233.5,"connectStart":233.5,"domainLookupEnd":233.5,"domainLookupStart":233.5,"fetchStart":233.5,"redirectEnd":0,"redirectStart":0,"requestStart":233.5,"responseEnd":858.7999999821186,"responseStart":858.7999999821186,"secureConnectionStart":233.5},{"duration":626.1999999880791,"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":233.59999999403954,"connectEnd":233.59999999403954,"connectStart":233.59999999403954,"domainLookupEnd":233.59999999403954,"domainLookupStart":233.59999999403954,"fetchStart":233.59999999403954,"redirectEnd":0,"redirectStart":0,"requestStart":233.59999999403954,"responseEnd":859.7999999821186,"responseStart":859.7999999821186,"secureConnectionStart":233.59999999403954},{"duration":209.80000001192093,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":562.7999999821186,"connectEnd":562.7999999821186,"connectStart":562.7999999821186,"domainLookupEnd":562.7999999821186,"domainLookupStart":562.7999999821186,"fetchStart":562.7999999821186,"redirectEnd":0,"redirectStart":0,"requestStart":562.7999999821186,"responseEnd":772.5999999940395,"responseStart":772.5999999940395,"secureConnectionStart":562.7999999821186},{"duration":86.09999999403954,"initiatorType":"link","name":"https://jira.mariadb.org/s/d5715adaadd168a9002b108b2b039b50-CDN/lu2bv2/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":808.7999999821186,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":808.7999999821186,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":894.8999999761581,"responseStart":0,"secureConnectionStart":0}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":56,"responseStart":225,"responseEnd":227,"domLoading":228,"domInteractive":1028,"domContentLoadedEventStart":1028,"domContentLoadedEventEnd":1069,"domComplete":1357,"loadEventStart":1357,"loadEventEnd":1358,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1013.8999999761581},{"name":"bigPipe.sidebar-id.end","time":1014.5999999940395},{"name":"bigPipe.activity-panel-pipe-id.start","time":1014.6999999880791},{"name":"bigPipe.activity-panel-pipe-id.end","time":1015.3999999761581},{"name":"activityTabFullyLoaded","time":1083.0999999940395}],"measures":[],"correlationId":"1565f91e025f6a","effectiveType":"4g","downlink":9.8,"rtt":0,"serverDuration":101,"dbReadsTimeInMs":16,"dbConnsTimeInMs":24,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}