| From: | Imran Zaheer <imran(dot)zhir(at)gmail(dot)com> |
|---|---|
| To: | Fujii Masao <masao(dot)fujii(at)gmail(dot)com> |
| Cc: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: Failing assertion while taking a restartpoint during crash recovery |
| Date: | 2026-08-18 04:37:14 |
| Message-ID: | CA+UBfakXLFhAGL7bKqTfYS2qtKLdYNGSsm9zYhH_LwespjJTkQ@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi
I was looking into the patch, and I was wondering if we could make use
of the following small changes.
* Instead of setting the shared state in StartupXLOG, why not set it
in the StartupSUBTRANS itself?
```
@@ -6234,7 +6234,6 @@ StartupXLOG(void)
* during recovery and need not be started yet.
*/
StartupSUBTRANS(oldestActiveXID);
- SetRecoverySubtransInitialized();
```
* This way we can also add an assertion that subtrans shouldn't
already be initialized.
```
@@ -307,6 +307,8 @@ StartupSUBTRANS(TransactionId oldestActiveXID)
LWLock *prevlock = NULL;
LWLock *lock;
+ Assert(!RecoverySubtransInitialized());
+
/*
* Since we don't expect pg_subtrans to be valid across crashes, we
* initialize the currently-active page(s) to zeroes during startup.
@@ -339,6 +341,8 @@ StartupSUBTRANS(TransactionId oldestActiveXID)
}
LWLockRelease(lock);
+
+ SetRecoverySubtransInitialized();
}
```
* Also we can add an assertion while truncating subtrans for safety.
```
@@ -405,6 +409,8 @@ TruncateSUBTRANS(TransactionId oldestXact)
{
int64 cutoffPage;
+ Assert(RecoverySubtransInitialized());
+
```
* There is is another subtrans call under StartupXLOG that can also be improved
```
@@ -6518,7 +6517,7 @@ StartupXLOG(void)
* Start up subtrans, if not already done for hot standby. (commit
* timestamps are started below, if necessary.)
*/
- if (standbyState == STANDBY_DISABLED)
+ if (standbyState == STANDBY_DISABLED && !RecoverySubtransInitialized())
StartupSUBTRANS(oldestActiveXID);
```
* Other than that we also call TruncateSUBTRANS() while creating a
checkpoint; maybe we can also improve the guard here, although the
assertion under TruncateSUBTRANS could be enough?
@@ -7879,7 +7878,7 @@ CreateCheckPoint(int flags)
* in subtrans.c). During recovery, though, we mustn't do this because
* StartupSUBTRANS hasn't been called yet.
*/
- if (!RecoveryInProgress())
+ if (!RecoveryInProgress() && RecoverySubtransInitialized())
TruncateSUBTRANS(GetOldestTransactionIdConsideredRunning());
Thoughts?
Thanks,
Imran Zaheer
| From | Date | Subject | |
|---|---|---|---|
| Next Message | vignesh C | 2026-08-18 04:54:25 | Re: Support EXCEPT for TABLES IN SCHEMA publications |
| Previous Message | Bertrand Drouvot | 2026-08-18 04:18:53 | Re: basebackup: do not verify checksums on pages written before enabling checksums |