Assertion failure while streaming toasted data

From: Pavan Deolasee <pavan(dot)deolasee(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Cc: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
Subject: Assertion failure while streaming toasted data
Date: 2021-05-25 06:36:38
Message-ID: CABOikdN-_858zojYN-2tNcHiVTw-nhxPwoQS4quExeweQfG1Ug@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

While working on an output plugin that uses streaming protocol, I hit an
assertion failure. Further investigations revealed a possible bug in core
Postgres. This must be new to PG14 since streaming support is new to this
release. I extended the test_decoding regression test to demonstrate the
failure. PFA

```
2021-05-25 11:32:19.493 IST client backend[68321] pg_regress/stream
STATEMENT: SELECT data FROM pg_logical_slot_get_changes('regression_slot',
NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '
1', 'stream-changes', '1');
TRAP: FailedAssertion("txn->size == 0", File: "reorderbuffer.c", Line:
3476, PID: 68321)
```

From my preliminary analysis, it looks like we fail to adjust the memory
accounting after streaming toasted tuples. More concretely, after
`ReorderBufferProcessPartialChange()` processes the in-progress
transaction, `ReorderBufferTruncateTXN()` truncates the accumulated
changed in the transaction, but fails to adjust the buffer size for toast
chunks. Maybe we are missing a call to `ReorderBufferToastReset()`
somewhere?

From what I see, the assertion only triggers when data is inserted via COPY
(multi-insert).

Let me know if anything else is needed to reproduce this.

Thanks,
Pavan

--
Pavan Deolasee
EnterpriseDB: https://www.enterprisedb.com

Attachment Content-Type Size
stream_toasted_txn_test.patch application/octet-stream 7.6 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Guillaume Lelarge 2021-05-25 06:40:58 Re: Issue on catalogs.sgml
Previous Message houzj.fnst@fujitsu.com 2021-05-25 06:35:38 RE: Parallel Inserts in CREATE TABLE AS