summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Black <daniel@mariadb.org>2022-07-11 12:52:16 +1000
committerDaniel Black <daniel@mariadb.org>2022-07-11 17:20:08 +1000
commit8e9978191a2e2a457f6378bd7e4173b9d220052b (patch)
tree06fc77f9c39180d6db18ed200c84e1f398ee2d08
parent0e9a255ec87add182f40d4c67d75e67827c0c3ec (diff)
downloadmariadb-git-preview-10.3-mdev-29015-avoid-wsl8443.tar.gz
MDEV-29015 innodb os_file_set_size WSL workaroundpreview-10.3-mdev-29015-avoid-wsl8443
WSL wasn't keeping stack of renamed files (https://github.com/microsoft/WSL/issues/8443) resulting in the fstat calls in os_file_set_size returning ENOENT and no fallocate fallback being possible. Users reported MySQL was ok, and it used my_seek to determine the size. We copy this concept here to avoid the WSL bug.
-rw-r--r--storage/innobase/os/os0file.cc28
1 files changed, 14 insertions, 14 deletions
diff --git a/storage/innobase/os/os0file.cc b/storage/innobase/os/os0file.cc
index 2c94ea6e393..1227b668ce4 100644
--- a/storage/innobase/os/os0file.cc
+++ b/storage/innobase/os/os0file.cc
@@ -5304,8 +5304,6 @@ os_file_set_size(
fallback:
#else
- struct stat statbuf;
-
if (is_sparse) {
bool success = !ftruncate(file, size);
if (!success) {
@@ -5319,17 +5317,18 @@ fallback:
# ifdef HAVE_POSIX_FALLOCATE
int err;
do {
- if (fstat(file, &statbuf)) {
+ os_offset_t current_size = my_seek(file, 0L, MY_SEEK_END,
+ MYF(MY_WME));
+ if (current_size == MY_FILEPOS_ERROR) {
err = errno;
- } else {
- os_offset_t current_size = statbuf.st_size;
- if (current_size >= size) {
- return true;
- }
- current_size &= ~4095ULL;
- err = posix_fallocate(file, current_size,
- size - current_size);
+ break;
}
+ if (current_size >= size) {
+ return true;
+ }
+ current_size &= ~4095ULL;
+ err = posix_fallocate(file, current_size, size - current_size);
+
} while (err == EINTR
&& srv_shutdown_state <= SRV_SHUTDOWN_INITIATED);
@@ -5363,10 +5362,11 @@ fallback:
}
}
#else
- if (fstat(file, &statbuf)) {
+ os_offset_t current_size = my_seek(file, 0L, MY_SEEK_END, MYF(MY_WME));
+ if (current_size == MY_FILEPOS_ERROR)
return false;
- }
- os_offset_t current_size = statbuf.st_size & ~4095ULL;
+
+ current_size &= ~4095ULL;
#endif
if (current_size >= size) {
return true;