Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit387483e

Browse files
committed
Tolerate ENOSYS failure from sync_file_range().
One unintended consequence of commit9ccdd7f was that Windows WSLusers started getting a panic whenever we tried to initiate dataflushing with sync_file_range(), because WSL does not implement thatsystem call. Previously, they got a stream of periodic warnings,which was also undesirable but at least ignorable.Prevent the panic by handling ENOSYS specially and skipping the panicpromotion with data_sync_elevel(). Also suppress future attemptsafter the first such failure so that the pre-existing problem ofnoisy warnings is improved.Back-patch to 9.6 (older branches were not affected in this way by9ccdd7f).Author: Thomas Munro and James SewellTested-by: James SewellReported-by: Bruce KleinDiscussion:https://postgr.es/m/CA+mCpegfOUph2U4ZADtQT16dfbkjjYNJL1bSTWErsazaFjQW9A@mail.gmail.com
1 parent58947fb commit387483e

File tree

1 file changed

+20
-1
lines changed
  • src/backend/storage/file

1 file changed

+20
-1
lines changed

‎src/backend/storage/file/fd.c

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,10 @@ pg_flush_data(int fd, off_t offset, off_t nbytes)
423423
#if defined(HAVE_SYNC_FILE_RANGE)
424424
{
425425
intrc;
426+
staticboolnot_implemented_by_kernel= false;
427+
428+
if (not_implemented_by_kernel)
429+
return;
426430

427431
/*
428432
* sync_file_range(SYNC_FILE_RANGE_WRITE), currently linux specific,
@@ -437,7 +441,22 @@ pg_flush_data(int fd, off_t offset, off_t nbytes)
437441
SYNC_FILE_RANGE_WRITE);
438442
if (rc!=0)
439443
{
440-
ereport(data_sync_elevel(WARNING),
444+
intelevel;
445+
446+
/*
447+
* For systems that don't have an implementation of
448+
* sync_file_range() such as Windows WSL, generate only one
449+
* warning and then suppress all further attempts by this process.
450+
*/
451+
if (errno==ENOSYS)
452+
{
453+
elevel=WARNING;
454+
not_implemented_by_kernel= true;
455+
}
456+
else
457+
elevel=data_sync_elevel(WARNING);
458+
459+
ereport(elevel,
441460
(errcode_for_file_access(),
442461
errmsg("could not flush dirty data: %m")));
443462
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp