Re: IO in wrong state on riscv64

From: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
To: Alexander Lakhin <exclusion(at)gmail(dot)com>
Cc: Andres Freund <andres(at)anarazel(dot)de>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, greg(at)burd(dot)me
Subject: Re: IO in wrong state on riscv64
Date: 2025-10-15 04:00:07
Message-ID: CA+hUKGKcdkNTkn9C2MT3zM3ZTVLZTZTiLKXkWVDYWh4w7MNACA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Oct 14, 2025 at 5:00 PM Alexander Lakhin <exclusion(at)gmail(dot)com> wrote:
> The replacements doesn't work for me, unfortunately: I have 3 out of 30
> 027_stream_regress test runs failed:
> 2025-10-13 21:27:26.161 UTC [4181290:5] pg_regress/brin ERROR: IO in wrong state: 0
> 2025-10-13 21:27:26.161 UTC [4181290:6] pg_regress/brin STATEMENT: CREATE TABLE brintest (byteacol bytea,

I wonder if the problem could be with buf->io_wref. In WaitIO() we do:

iow = buf->io_wref;
UnlockBufHdr(buf, buf_state);
...
pgaio_wref_wait(&iow);

... but UnlockBufHdr() is only concerned with write ordering:

static inline void
UnlockBufHdr(BufferDesc *desc, uint32 buf_state)
{
pg_write_barrier();
pg_atomic_write_u32(&desc->state, buf_state & (~BM_LOCKED));
}

What happens if you insert pg_memory_barrier() after the line that
reads buf->io_wref?

Does this reproduce on REL_18_STABLE?

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message shveta malik 2025-10-15 04:11:31 Re: Logical Replication of sequences
Previous Message Chao Li 2025-10-15 03:37:05 Re: [PROPOSAL] Termination of Background Workers for ALTER/DROP DATABASE