Skip to content

Commit 6b8173b

Browse files
committed
MDEV-11520: Retry posix_fallocate() after EINTR.
The function posix_fallocate() as well as the Linux system call fallocate() can return EINTR when the operation was interrupted by a signal. In that case, keep retrying the operation, except if InnoDB shutdown has been initiated.
1 parent 75f6067 commit 6b8173b

File tree

4 files changed

+20
-4
lines changed

4 files changed

+20
-4
lines changed

storage/innobase/fil/fil0fil.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4140,7 +4140,11 @@ fil_extend_space_to_desired_size(
41404140
= (start_page_no - file_start_page_no) * page_size;
41414141
ib_int64_t len
41424142
= (size_after_extend - start_page_no) * page_size;
4143-
int err = posix_fallocate(node->handle, start_offset, len);
4143+
int err;
4144+
do {
4145+
err = posix_fallocate(node->handle, start_offset, len);
4146+
} while (err == EINTR
4147+
&& srv_shutdown_state == SRV_SHUTDOWN_NONE);
41444148

41454149
success = !err;
41464150

storage/innobase/os/os0file.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2032,7 +2032,11 @@ os_file_set_size(
20322032

20332033
#ifdef HAVE_POSIX_FALLOCATE
20342034
if (srv_use_posix_fallocate) {
2035-
int err = posix_fallocate(file, 0, desired_size);
2035+
int err;
2036+
do {
2037+
err = posix_fallocate(file, 0, desired_size);
2038+
} while (err == EINTR
2039+
&& srv_shutdown_state == SRV_SHUTDOWN_NONE);
20362040
if (err) {
20372041
fprintf(stderr,
20382042
"InnoDB: Error: preallocating %lld bytes for"

storage/xtradb/fil/fil0fil.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4975,7 +4975,11 @@ fil_extend_space_to_desired_size(
49754975
= (start_page_no - file_start_page_no) * page_size;
49764976
ib_int64_t len
49774977
= (size_after_extend - start_page_no) * page_size;
4978-
int err = posix_fallocate(node->handle, start_offset, len);
4978+
int err;
4979+
do {
4980+
err = posix_fallocate(node->handle, start_offset, len);
4981+
} while (err == EINTR
4982+
&& srv_shutdown_state == SRV_SHUTDOWN_NONE);
49794983

49804984
success = !err;
49814985

storage/xtradb/os/os0file.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2189,7 +2189,11 @@ os_file_set_size(
21892189

21902190
#ifdef HAVE_POSIX_FALLOCATE
21912191
if (srv_use_posix_fallocate) {
2192-
int err = posix_fallocate(file, 0, desired_size);
2192+
int err;
2193+
do {
2194+
err = posix_fallocate(file, 0, desired_size);
2195+
} while (err == EINTR
2196+
&& srv_shutdown_state == SRV_SHUTDOWN_NONE);
21932197
if (err) {
21942198
fprintf(stderr,
21952199
"InnoDB: Error: preallocating %lld bytes for"

0 commit comments

Comments
 (0)