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

Commit483520e

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 parentf275225 commit483520e

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
@@ -420,6 +420,10 @@ pg_flush_data(int fd, off_t offset, off_t nbytes)
420420
#if defined(HAVE_SYNC_FILE_RANGE)
421421
{
422422
intrc;
423+
staticboolnot_implemented_by_kernel= false;
424+
425+
if (not_implemented_by_kernel)
426+
return;
423427

424428
/*
425429
* sync_file_range(SYNC_FILE_RANGE_WRITE), currently linux specific,
@@ -434,7 +438,22 @@ pg_flush_data(int fd, off_t offset, off_t nbytes)
434438
SYNC_FILE_RANGE_WRITE);
435439
if (rc!=0)
436440
{
437-
ereport(data_sync_elevel(WARNING),
441+
intelevel;
442+
443+
/*
444+
* For systems that don't have an implementation of
445+
* sync_file_range() such as Windows WSL, generate only one
446+
* warning and then suppress all further attempts by this process.
447+
*/
448+
if (errno==ENOSYS)
449+
{
450+
elevel=WARNING;
451+
not_implemented_by_kernel= true;
452+
}
453+
else
454+
elevel=data_sync_elevel(WARNING);
455+
456+
ereport(elevel,
438457
(errcode_for_file_access(),
439458
errmsg("could not flush dirty data: %m")));
440459
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp