initdb -c "track_commit_timestamp=on" crashes in case of debug build

From: "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com>
To: "'pgsql-hackers(at)lists(dot)postgresql(dot)org'" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: initdb -c "track_commit_timestamp=on" crashes in case of debug build
Date: 2025-01-06 13:14:44
Message-ID: OSCPR01MB14966FF9E4C4145F37B937E52F5102@OSCPR01MB14966.jpnprd01.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi hackers,

While working on another thread I found $subject. I've tested only on master,
but I doubt this could happen even on PG16 and 17. You can reproduce by:
```
$ initdb -D data -c "track_commit_timestamp=on"
...
child process was terminated by signal 6: Aborted
initdb: removing data directory "data"
```

Back-trace I got is shown in [1].

IIUC the crash was caused at TransactionIdSetCommitTs(), and the primal reason was that
commit_ts module tried to store the bootstrap transaction.

In the first place I'm not sure we want to fix this because this happens only for
the debug mode... but if needed, the easiest way is not to activate the commit_ts
in the bootstrap mode. I think this fix is enough because pg_last_committed_xact()
and TransactionIdGetCommitTsData() won't seek the un-normal xid.
Attached patch was created based on the idea.

Thought?

[1]:
```
(gdb) bt
#0 0x00007f1da8dd8387 in __GI_raise (sig=sig(at)entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:55
#1 0x00007f1da8dd9a78 in __GI_abort () at abort.c:90
#2 0x0000000000bd3c0c in ExceptionalCondition (conditionName=0xc7a21b "TransactionIdIsNormal(xid)",
fileName=0xc7a20f "commit_ts.c", lineNumber=255) at assert.c:66
#3 0x000000000056467f in TransactionIdSetCommitTs (xid=1, ts=789482588771230, nodeid=0, slotno=0) at commit_ts.c:255
#4 0x00000000005645c3 in SetXidCommitTsInPage (xid=1, nsubxids=0, subxids=0x0, ts=789482588771230, nodeid=0, pageno=0)
at commit_ts.c:234
#5 0x0000000000564494 in TransactionTreeSetCommitTsData (xid=1, nsubxids=0, subxids=0x0, timestamp=789482588771230,
nodeid=0) at commit_ts.c:190
#6 0x0000000000579c18 in RecordTransactionCommit () at xact.c:1467
#7 0x000000000057aa15 in CommitTransaction () at xact.c:2364
#8 0x000000000057b7cf in CommitTransactionCommandInternal () at xact.c:3194
#9 0x000000000057b738 in CommitTransactionCommand () at xact.c:3155
#10 0x00000000005b1b0e in BootstrapModeMain (argc=7, argv=0x1be1048, check_only=false) at bootstrap.c:390
#11 0x00000000007de1c5 in main (argc=8, argv=0x1be1040) at main.c:21
```

Best regards,
Hayato Kuroda
FUJITSU LIMITED

Attachment Content-Type Size
0001-Avoid-activating-commit_ts-while-bootstrap.patch application/octet-stream 910 bytes

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Rahila Syed 2025-01-06 13:16:30 Re: Enhancing Memory Context Statistics Reporting
Previous Message Pavel Stehule 2025-01-06 12:21:09 Re: Re: proposal: schema variables