ERROR: tuple to be updated was already modified by an operation triggered by the current command

Richard Guo <guofenglinux@gmail.com>

From: Richard Guo <guofenglinux@gmail.com>
To: PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>
Date: 2025-01-23T09:11:44Z
Lists: pgsql-bugs
I came across $SUBJECT, which can be reproduced using the queries
below.

# create temporary table p (a int primary key) on commit delete rows;
CREATE TABLE
# create temporary table c () inherits (p);
CREATE TABLE

# analyze; -- no error
ANALYZE

# drop table c;
DROP TABLE

# analyze; -- error
ERROR:  tuple to be updated was already modified by an operation
triggered by the current command

This error happens in heap_inplace_lock(), and git-bisect says the
first bad commit is:

a07e03fd8fa7daf4d1356f7cb501ffe784ea6257 is the first bad commit
commit a07e03fd8fa7daf4d1356f7cb501ffe784ea6257
Author: Noah Misch <noah@leadboat.com>
Date:   Tue Sep 24 15:25:18 2024 -0700

    Fix data loss at inplace update after heap_update().

... which introduced heap_inplace_lock().

Is this error expected, or could it be a bug?

Thanks
Richard



Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Avoid ERROR at ON COMMIT DELETE ROWS after relhassubclass=f.

  2. Fix data loss at inplace update after heap_update().

  3. Don't lose partitioned table reltuples=0 after relhassubclass=f.