pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alexander Lakhin <exclusion@gmail.com>
To: Tender Wang <tndrwang@gmail.com>
Cc: PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>
Subject: Re: BUG #18385: Assert("strategy_delta >= 0") in BgBufferSync() fails due to race condition
Date: Wed, 13 Mar 2024 11:00:00 +0300
Message-ID: <74affb73-113e-0300-dc43-ea73535c23b9@gmail.com> (raw)
In-Reply-To: <CAHewXNmGmo7RPzZob+UL47rmujXAkEmwhHcYM+f8kye41SybJA@mail.gmail.com>
References: <18385-eaccb1d63684c704@postgresql.org>
	<CAHewXNmGmo7RPzZob+UL47rmujXAkEmwhHcYM+f8kye41SybJA@mail.gmail.com>

Hi Tender Wang,

13.03.2024 09:50, Tender Wang wrote:
> Hi Alexander,
>    I haven't been able to reproduce this issue on my machine(2 vCPU, 2GB memory).
>
>  Can you reproduce this issue reliably on your machine?

Thanks for your attention to this issue!

On my 12-core workstation, where pgbench shows approximately 2500 tps,
`pgbench -t 10000 -c 40` failed on iterations 1, 1, 3:
...
number of transactions actually processed: 398639/400000
number of failed transactions: 0 (0.000%)
latency average = 15.931 ms
initial connection time = 56.806 ms
tps = 2510.845701 (without initial connection time)
pgbench: error: Run was aborted; the above results are incomplete.
...

The server built with gcc,
CPPFLAGS="-O0" ./configure --enable-debug --enable-cassert ...

I have also intensified bgwriter as follows:
          rc = WaitLatch(MyLatch,
                         WL_LATCH_SET | WL_TIMEOUT | WL_EXIT_ON_PM_DEATH,
-                       BgWriterDelay /* ms */ , WAIT_EVENT_BGWRITER_MAIN);
+                       1 /* ms */ , WAIT_EVENT_BGWRITER_MAIN);

That is, I have the attached modification applied and the following in my
extra.config:
fsync = off
autovacuum = off
shared_buffers = '1MB'

Best regards,
Alexander

Attachments:

debug-18385.patch (text/x-patch, 1017B) download diff --git a/src/backend/postmaster/bgwriter.c b/src/backend/postmaster/bgwriter.c index da2d95b926..4dcb7cddd7 100644 --- a/src/backend/postmaster/bgwriter.c +++ b/src/backend/postmaster/bgwriter.c @@ -298,7 +298,7 @@ BackgroundWriterMain(void) */ rc = WaitLatch(MyLatch, WL_LATCH_SET | WL_TIMEOUT | WL_EXIT_ON_PM_DEATH, - BgWriterDelay /* ms */ , WAIT_EVENT_BGWRITER_MAIN); + 1 /* ms */ , WAIT_EVENT_BGWRITER_MAIN); /* * If no latch event and BgBufferSync says nothing's happening, extend diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 3611357fa3..ecf70a036b 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -415,6 +415,7 @@ StrategySyncStart(uint32 *complete_passes, uint32 *num_buf_alloc) { *num_buf_alloc = pg_atomic_exchange_u32(&StrategyControl->numBufferAllocs, 0); } +pg_usleep(300); SpinLockRelease(&StrategyControl->buffer_strategy_lock); return result; }

view thread (5+ messages)  latest in thread

Message-ID: <74affb73-113e-0300-dc43-ea73535c23b9@gmail.com>
Permalink:  ../74affb73-113e-0300-dc43-ea73535c23b9@gmail.com/
Also on:    postgresql.org/message-id/74affb73-113e-0300-dc43-ea73535c23b9@gmail.com

 ·  · 

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-bugs@postgresql.org
  Cc: exclusion@gmail.com, tndrwang@gmail.com, pgsql-bugs@lists.postgresql.org
  Subject: Re: BUG #18385: Assert("strategy_delta >= 0") in BgBufferSync() fails due to race condition
  In-Reply-To: <74affb73-113e-0300-dc43-ea73535c23b9@gmail.com>

* 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