It's intended to replace all naked char * and const std::string:: & in functions arguments. string_view is better because of a clear semantics: non-owning string. When you see a member or variable const char *smth; you can't say whether it own its buffer or not. For argument you don't know whether ownership was transferred to function or not. Similar to return char * from function.
string_view makes code easier to read. Also it has begin(), end() member which allows it's data to be used in range-for loops.
It seems that the function fsp_path_to_space_name() is initially accessing one byte before the start of the string, in the first iteration of string_view::rfind() with the default parameter pos=npos, tripping AddressSanitizer in many tests. I reverted the change due to this. Please fix and test with ASAN.
Marko Mäkelä
added a comment - It seems that the function fsp_path_to_space_name() is initially accessing one byte before the start of the string, in the first iteration of string_view::rfind() with the default parameter pos=npos , tripping AddressSanitizer in many tests. I reverted the change due to this. Please fix and test with ASAN.
The originally found issue may have been resolved by MDEV-25312, which removed the data member fil_space_t::name.
I think that there needs to be some measurable benefit from such refactoring. I see that we currently use std::string (and are unnecessarily copying some data) in file_name_t::name and renamed_spaces. We could make those point directly to the redo log parse buffer. The data would only have to be copied at the end of each non-final recv_sys_t::apply() before the underlying buffer would be invalidated by recv_sys_t::free(). In that way, we would avoid copying any file name strings when only one recovery batch is needed.
Marko Mäkelä
added a comment - The originally found issue may have been resolved by MDEV-25312 , which removed the data member fil_space_t::name .
I think that there needs to be some measurable benefit from such refactoring. I see that we currently use std::string (and are unnecessarily copying some data) in file_name_t::name and renamed_spaces . We could make those point directly to the redo log parse buffer. The data would only have to be copied at the end of each non-final recv_sys_t::apply() before the underlying buffer would be invalidated by recv_sys_t::free() . In that way, we would avoid copying any file name strings when only one recovery batch is needed.
I think that this basically already exists as LEX_STRING and LEX_CSTRING. We perhaps should not develop several ways of doing the same thing, and I am afraid that there would be strong opposition if the existing classes were renamed or refactored.
Marko Mäkelä
added a comment - I think that this basically already exists as LEX_STRING and LEX_CSTRING . We perhaps should not develop several ways of doing the same thing, and I am afraid that there would be strong opposition if the existing classes were renamed or refactored.
People
Eugene Kosov (Inactive)
Eugene Kosov (Inactive)
Votes:
0Vote for this issue
Watchers:
3Start watching this issue
Dates
Created:
Updated:
Resolved:
Git Integration
Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.
{"report":{"fcp":784.1999999880791,"ttfb":185.19999998807907,"pageVisibility":"visible","entityId":78633,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":1,"journeyId":"957b26f5-0bfc-40ff-8ef5-93b71292491b","navigationType":0,"readyForUser":853.4000000357628,"redirectCount":0,"resourceLoadedEnd":996.5,"resourceLoadedStart":190.80000001192093,"resourceTiming":[{"duration":115.30000001192093,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":190.80000001192093,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":190.80000001192093,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":306.10000002384186,"responseStart":0,"secureConnectionStart":0},{"duration":115.30000001192093,"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":191.10000002384186,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":191.10000002384186,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":306.4000000357628,"responseStart":0,"secureConnectionStart":0},{"duration":123.90000003576279,"initiatorType":"script","name":"https://jira.mariadb.org/s/fbf975c0cce4b1abf04784eeae9ba1f4-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":191.19999998807907,"connectEnd":191.19999998807907,"connectStart":191.19999998807907,"domainLookupEnd":191.19999998807907,"domainLookupStart":191.19999998807907,"fetchStart":191.19999998807907,"redirectEnd":0,"redirectStart":0,"requestStart":191.19999998807907,"responseEnd":315.10000002384186,"responseStart":315.10000002384186,"secureConnectionStart":191.19999998807907},{"duration":209.19999998807907,"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":191.4000000357628,"connectEnd":191.4000000357628,"connectStart":191.4000000357628,"domainLookupEnd":191.4000000357628,"domainLookupStart":191.4000000357628,"fetchStart":191.4000000357628,"redirectEnd":0,"redirectStart":0,"requestStart":191.4000000357628,"responseEnd":400.60000002384186,"responseStart":400.60000002384186,"secureConnectionStart":191.4000000357628},{"duration":212.80000001192093,"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":191.60000002384186,"connectEnd":191.60000002384186,"connectStart":191.60000002384186,"domainLookupEnd":191.60000002384186,"domainLookupStart":191.60000002384186,"fetchStart":191.60000002384186,"redirectEnd":0,"redirectStart":0,"requestStart":191.60000002384186,"responseEnd":404.4000000357628,"responseStart":404.4000000357628,"secureConnectionStart":191.60000002384186},{"duration":213.30000001192093,"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":191.69999998807907,"connectEnd":191.69999998807907,"connectStart":191.69999998807907,"domainLookupEnd":191.69999998807907,"domainLookupStart":191.69999998807907,"fetchStart":191.69999998807907,"redirectEnd":0,"redirectStart":0,"requestStart":191.69999998807907,"responseEnd":405,"responseStart":405,"secureConnectionStart":191.69999998807907},{"duration":213.69999998807907,"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":192,"connectEnd":192,"connectStart":192,"domainLookupEnd":192,"domainLookupStart":192,"fetchStart":192,"redirectEnd":0,"redirectStart":0,"requestStart":192,"responseEnd":405.69999998807907,"responseStart":405.69999998807907,"secureConnectionStart":192},{"duration":265.5999999642372,"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":192.10000002384186,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":192.10000002384186,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":457.69999998807907,"responseStart":0,"secureConnectionStart":0},{"duration":214.10000002384186,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":192.30000001192093,"connectEnd":192.30000001192093,"connectStart":192.30000001192093,"domainLookupEnd":192.30000001192093,"domainLookupStart":192.30000001192093,"fetchStart":192.30000001192093,"redirectEnd":0,"redirectStart":0,"requestStart":192.30000001192093,"responseEnd":406.4000000357628,"responseStart":406.4000000357628,"secureConnectionStart":192.30000001192093},{"duration":265.30000001192093,"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":192.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":192.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":457.80000001192093,"responseStart":0,"secureConnectionStart":0},{"duration":214.69999998807907,"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":192.60000002384186,"connectEnd":192.60000002384186,"connectStart":192.60000002384186,"domainLookupEnd":192.60000002384186,"domainLookupStart":192.60000002384186,"fetchStart":192.60000002384186,"redirectEnd":0,"redirectStart":0,"requestStart":192.60000002384186,"responseEnd":407.30000001192093,"responseStart":407.30000001192093,"secureConnectionStart":192.60000002384186},{"duration":444.9000000357628,"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.69999998807907,"connectEnd":197.69999998807907,"connectStart":197.69999998807907,"domainLookupEnd":197.69999998807907,"domainLookupStart":197.69999998807907,"fetchStart":197.69999998807907,"redirectEnd":0,"redirectStart":0,"requestStart":197.69999998807907,"responseEnd":642.6000000238419,"responseStart":642.6000000238419,"secureConnectionStart":197.69999998807907},{"duration":798.6999999880791,"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":197.80000001192093,"connectEnd":197.80000001192093,"connectStart":197.80000001192093,"domainLookupEnd":197.80000001192093,"domainLookupStart":197.80000001192093,"fetchStart":197.80000001192093,"redirectEnd":0,"redirectStart":0,"requestStart":197.80000001192093,"responseEnd":996.5,"responseStart":996.5,"secureConnectionStart":197.80000001192093},{"duration":240.10000002384186,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":469.30000001192093,"connectEnd":469.30000001192093,"connectStart":469.30000001192093,"domainLookupEnd":469.30000001192093,"domainLookupStart":469.30000001192093,"fetchStart":469.30000001192093,"redirectEnd":0,"redirectStart":0,"requestStart":469.30000001192093,"responseEnd":709.4000000357628,"responseStart":709.3000000119209,"secureConnectionStart":469.30000001192093},{"duration":315,"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":739.4000000357628,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":739.4000000357628,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1054.4000000357628,"responseStart":0,"secureConnectionStart":0},{"duration":282,"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":740.1999999880791,"connectEnd":740.1999999880791,"connectStart":740.1999999880791,"domainLookupEnd":740.1999999880791,"domainLookupStart":740.1999999880791,"fetchStart":740.1999999880791,"redirectEnd":0,"redirectStart":0,"requestStart":740.1999999880791,"responseEnd":1022.1999999880791,"responseStart":1022.1999999880791,"secureConnectionStart":740.1999999880791},{"duration":288.19999998807907,"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":740.6000000238419,"connectEnd":740.6000000238419,"connectStart":740.6000000238419,"domainLookupEnd":740.6000000238419,"domainLookupStart":740.6000000238419,"fetchStart":740.6000000238419,"redirectEnd":0,"redirectStart":0,"requestStart":740.6000000238419,"responseEnd":1028.800000011921,"responseStart":1028.800000011921,"secureConnectionStart":740.6000000238419}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":23,"responseStart":186,"responseEnd":192,"domLoading":189,"domInteractive":1016,"domContentLoadedEventStart":1016,"domContentLoadedEventEnd":1055,"domComplete":1315,"loadEventStart":1315,"loadEventEnd":1316,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":998.3000000119209},{"name":"bigPipe.sidebar-id.end","time":999.3000000119209},{"name":"bigPipe.activity-panel-pipe-id.start","time":999.5},{"name":"bigPipe.activity-panel-pipe-id.end","time":1000.6000000238419},{"name":"activityTabFullyLoaded","time":1103.800000011921}],"measures":[],"correlationId":"2b839b68591692","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":105,"dbReadsTimeInMs":12,"dbConnsTimeInMs":21,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
It seems that the function fsp_path_to_space_name() is initially accessing one byte before the start of the string, in the first iteration of string_view::rfind() with the default parameter pos=npos, tripping AddressSanitizer in many tests. I reverted the change due to this. Please fix and test with ASAN.