Skip to content

Commit 29c776c

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 d04d835 commit 29c776c

File tree

4 files changed

+24
-4
lines changed

4 files changed

+24
-4
lines changed

storage/innobase/fil/fil0fil.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5023,7 +5023,12 @@ fil_extend_space_to_desired_size(
50235023
= size_after_extend - start_page_no;
50245024
const os_offset_t len = os_offset_t(n_pages) * page_size;
50255025

5026-
int err = posix_fallocate(node->handle, start_offset, len);
5026+
int err;
5027+
do {
5028+
err = posix_fallocate(node->handle, start_offset, len);
5029+
} while (err == EINTR
5030+
&& srv_shutdown_state == SRV_SHUTDOWN_NONE);
5031+
50275032
success = !err;
50285033
if (!success) {
50295034
ib_logf(IB_LOG_LEVEL_ERROR, "extending file %s"

storage/innobase/os/os0file.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2130,7 +2130,12 @@ os_file_set_size(
21302130

21312131
#ifdef HAVE_POSIX_FALLOCATE
21322132
if (srv_use_posix_fallocate) {
2133-
int err = posix_fallocate(file, 0, size);
2133+
int err;
2134+
do {
2135+
err = posix_fallocate(file, 0, size);
2136+
} while (err == EINTR
2137+
&& srv_shutdown_state == SRV_SHUTDOWN_NONE);
2138+
21342139
if (err) {
21352140
ib_logf(IB_LOG_LEVEL_ERROR,
21362141
"preallocating " INT64PF " bytes for"

storage/xtradb/fil/fil0fil.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5063,7 +5063,12 @@ fil_extend_space_to_desired_size(
50635063
= size_after_extend - start_page_no;
50645064
const os_offset_t len = os_offset_t(n_pages) * page_size;
50655065

5066-
int err = posix_fallocate(node->handle, start_offset, len);
5066+
int err;
5067+
do {
5068+
err = posix_fallocate(node->handle, start_offset, len);
5069+
} while (err == EINTR
5070+
&& srv_shutdown_state == SRV_SHUTDOWN_NONE);
5071+
50675072
success = !err;
50685073
if (!success) {
50695074
ib_logf(IB_LOG_LEVEL_ERROR, "extending file %s"

storage/xtradb/os/os0file.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2348,7 +2348,12 @@ os_file_set_size(
23482348

23492349
#ifdef HAVE_POSIX_FALLOCATE
23502350
if (srv_use_posix_fallocate) {
2351-
int err = posix_fallocate(file, 0, size);
2351+
int err;
2352+
do {
2353+
err = posix_fallocate(file, 0, size);
2354+
} while (err == EINTR
2355+
&& srv_shutdown_state == SRV_SHUTDOWN_NONE);
2356+
23522357
if (err) {
23532358
ib_logf(IB_LOG_LEVEL_ERROR,
23542359
"preallocating " INT64PF " bytes for"

0 commit comments

Comments
 (0)