mirror of
https://github.com/postgres/postgres.git
synced 2025-04-22 23:02:54 +03:00
Promote the assertion that XLogBeginInsert() is not called twice into ERROR.
Seems like cheap insurance for WAL bugs. A spurious call to XLogBeginInsert() in itself would be fairly harmless, but if there is any data registered and the insertion is not completed/cancelled properly, there is a risk that the data ends up in a wrong WAL record. Per Jeff Janes's suggestion.
This commit is contained in:
parent
a45c70acf3
commit
a32c3ec893
@ -122,12 +122,14 @@ XLogBeginInsert(void)
|
|||||||
Assert(max_registered_block_id == 0);
|
Assert(max_registered_block_id == 0);
|
||||||
Assert(mainrdata_last == (XLogRecData *) &mainrdata_head);
|
Assert(mainrdata_last == (XLogRecData *) &mainrdata_head);
|
||||||
Assert(mainrdata_len == 0);
|
Assert(mainrdata_len == 0);
|
||||||
Assert(!begininsert_called);
|
|
||||||
|
|
||||||
/* cross-check on whether we should be here or not */
|
/* cross-check on whether we should be here or not */
|
||||||
if (!XLogInsertAllowed())
|
if (!XLogInsertAllowed())
|
||||||
elog(ERROR, "cannot make new WAL entries during recovery");
|
elog(ERROR, "cannot make new WAL entries during recovery");
|
||||||
|
|
||||||
|
if (begininsert_called)
|
||||||
|
elog(ERROR, "XLogBeginInsert was already called");
|
||||||
|
|
||||||
begininsert_called = true;
|
begininsert_called = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user