pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvaro.herrera@enterprisedb.com>
Subject: [PATCH] Add some debugging around mdzeroextend
Date: Fri, 5 Jul 2024 12:51:42 +0200

This is all new code, so it could have bugs.
---
 src/backend/storage/file/fd.c |  7 +++++++
 src/backend/storage/smgr/md.c | 12 ++++++++----
 2 files changed, 15 insertions(+), 4 deletions(-)

inline patch 1: src/backend/storage/file/fd.c, src/backend/storage/smgr/md.c (+15/-4 lines) download inline-1.patchdiff --git a/src/backend/storage/file/fd.c b/src/backend/storage/file/fd.c index 16b3e8f9058..a5db22b9b37 100644 --- a/src/backend/storage/file/fd.c +++ b/src/backend/storage/file/fd.c @@ -2347,6 +2347,13 @@ retry: */ if (returnCode != EINVAL && returnCode != EOPNOTSUPP) return -1; + + if (returnCode != EOPNOTSUPP) + ereport(WARNING, + errcode(ERRCODE_WARNING), + errmsg("could not allocate additional %lld bytes from position %lld in file \"%s\", retrying by zeroing: %m", + (long long) amount, (long long) offset, + VfdCache[file].fileName)); #endif return FileZero(file, offset, amount, wait_event_info); diff --git a/src/backend/storage/smgr/md.c b/src/backend/storage/smgr/md.c index fdecbad1709..ac5e325f8ec 100644 --- a/src/backend/storage/smgr/md.c +++ b/src/backend/storage/smgr/md.c @@ -580,15 +580,17 @@ mdzeroextend(SMgrRelation reln, ForkNumber forknum, if (numblocks > 8) { int ret; + off_t addbytes = (off_t) BLCKSZ * numblocks; ret = FileFallocate(v->mdfd_vfd, - seekpos, (off_t) BLCKSZ * numblocks, + seekpos, addbytes, WAIT_EVENT_DATA_FILE_EXTEND); if (ret != 0) { ereport(ERROR, errcode_for_file_access(), - errmsg("could not extend file \"%s\" with FileFallocate(): %m", + errmsg("could not allocate additional %lld bytes from position %lld in file \"%s\": %m", + (long long) addbytes, (long long) seekpos, FilePathName(v->mdfd_vfd)), errhint("Check free disk space.")); } @@ -596,6 +598,7 @@ mdzeroextend(SMgrRelation reln, ForkNumber forknum, else { int ret; + off_t addbytes = (off_t) BLCKSZ * numblocks; /* * Even if we don't want to use fallocate, we can still extend a @@ -605,12 +608,13 @@ mdzeroextend(SMgrRelation reln, ForkNumber forknum, * whole length of the extension. */ ret = FileZero(v->mdfd_vfd, - seekpos, (off_t) BLCKSZ * numblocks, + seekpos, addbytes, WAIT_EVENT_DATA_FILE_EXTEND); if (ret < 0) ereport(ERROR, errcode_for_file_access(), - errmsg("could not extend file \"%s\": %m", + errmsg("could not zero additional %lld bytes from position %lld file \"%s\": %m", + (long long) addbytes, (long long) seekpos, FilePathName(v->mdfd_vfd)), errhint("Check free disk space.")); } -- 2.39.2
--rjbc3qehavvp44am--

Message-ID: <no-message-id-49430@localhost>
Permalink:  ../no-message-id-49430@localhost/
Also on:    postgresql.org/message-id/no-message-id-49430@localhost

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-general@postgresql.org
  Cc: alvaro.herrera@enterprisedb.com
  Subject: Re: [PATCH] Add some debugging around mdzeroextend
  In-Reply-To: <no-message-id-49430@localhost>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox