public inbox for [email protected]help / color / mirror / Atom feed
[PATCH 1/2] Make xact.h usable in frontend. 2+ messages / 2 participants [nested] [flat]
* [PATCH 1/2] Make xact.h usable in frontend. @ 2020-08-12 20:07 Heikki Linnakangas <[email protected]> 0 siblings, 0 replies; 2+ messages in thread From: Heikki Linnakangas @ 2020-08-12 20:07 UTC (permalink / raw) xact.h included utils/datetime.h, which cannot be used in the frontend (it includes fmgr.h, which needs Datum). But xact.h only needs the definition of TimestampTz from it, which is available directly in datatypes/timestamp.h. Change xact.h to include that instead of utils/datetime.h, so that it can be used in client programs. --- src/backend/nodes/params.c | 1 + src/backend/utils/time/snapmgr.c | 2 ++ src/include/access/xact.h | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/backend/nodes/params.c b/src/backend/nodes/params.c index 1719119fc28..bce0c7e72b2 100644 --- a/src/backend/nodes/params.c +++ b/src/backend/nodes/params.c @@ -16,6 +16,7 @@ #include "postgres.h" #include "access/xact.h" +#include "fmgr.h" #include "mb/stringinfo_mb.h" #include "nodes/params.h" #include "parser/parse_node.h" diff --git a/src/backend/utils/time/snapmgr.c b/src/backend/utils/time/snapmgr.c index 6b6c8571e23..02b51bc4fe0 100644 --- a/src/backend/utils/time/snapmgr.c +++ b/src/backend/utils/time/snapmgr.c @@ -53,6 +53,7 @@ #include "access/xact.h" #include "access/xlog.h" #include "catalog/catalog.h" +#include "datatype/timestamp.h" #include "lib/pairingheap.h" #include "miscadmin.h" #include "storage/predicate.h" @@ -67,6 +68,7 @@ #include "utils/resowner_private.h" #include "utils/snapmgr.h" #include "utils/syscache.h" +#include "utils/timestamp.h" /* diff --git a/src/include/access/xact.h b/src/include/access/xact.h index c18554bae2c..9f9dc7d3354 100644 --- a/src/include/access/xact.h +++ b/src/include/access/xact.h @@ -16,11 +16,11 @@ #include "access/transam.h" #include "access/xlogreader.h" +#include "datatype/timestamp.h" #include "lib/stringinfo.h" #include "nodes/pg_list.h" #include "storage/relfilenode.h" #include "storage/sinval.h" -#include "utils/datetime.h" /* * Maximum size of Global Transaction ID (including '\0'). -- 2.20.1 --------------2C164649926A2BC8A5FD8CB8 Content-Type: text/x-patch; charset=UTF-8; name="0002-Mark-commit-and-abort-WAL-records-with-XLR_SPECIAL_R.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Mark-commit-and-abort-WAL-records-with-XLR_SPECIAL_R.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: An improvement of ProcessTwoPhaseBuffer logic @ 2024-12-25 16:18 Vitaly Davydov <[email protected]> 0 siblings, 0 replies; 2+ messages in thread From: Vitaly Davydov @ 2024-12-25 16:18 UTC (permalink / raw) To: Michael Paquier <[email protected]>; +Cc: pgsql-hackers Hi Michael, Thank you for the explanation and the patch! I'm happy, that I seem to be on the right way. On Wednesday, December 25, 2024 08:04 MSK, Michael Paquier <[email protected]> wrote: > Vitaly, have you seen that in the wild as an effect of future 2PC files? I haven't heard about this problem in production, but I've encountered it when I did some development in two-phase functionality. I fixed it by swapping the if blocks and it solved my problem. It is pretty easy to reproduce it on the master branch: 1. Start an instance with enabled prepared transactions 2. Create a simple prepared transaction 3. Do checkpoint to write the transaction two-phase state into a file in pg_twophase subdirectory 4. Copy the created file, change its name to reflect a future xid (in my case: cp 00000000000002E8 00000000000FF2E8) 5. Commit the prepared transaction 6. Stop the instance with -m immediate 7. Start the instance After starting, you can get an error like "could not start server". In the log file you can find a message like: LOG: database system was not properly shut down; automatic recovery in progress FATAL: could not access status of transaction 1045224 DETAIL: Could not read from file "pg_xact/0000" at offset 253952: read too few bytes. 2024-12-25 18:38:30.606 MSK [795557] LOG: startup process (PID 795560) exited with exit code 1 I tried your patch and it seems the server is started successfully. But I've found another problem in my synthetic test - it can not remove the file with the following message: LOG: database system was not properly shut down; automatic recovery in progress WARNING: removing future two-phase state file for transaction 1045224 WARNING: could not remove file "pg_twophase/FFFFFFFF000FF2E8": No such file or directory LOG: redo starts at 0/1762978 The fill will never be removed automatically. I guess, it is because we incorrectly calculate the two-phase file name using TwoPhaseFilePath in RemoveTwoPhaseFile in this scenario. It can be fixed if to pass file path directly from RecoverPreparedTransactions or StandbyRecoverPreparedTransaction into ProcessTwoPhaseBuffer -> RemoveTwoPhaseFile. I did it in the proposed patch https://www.postgresql.org/message-id/cedbe-65e0c000-1-6db17700%40133269862 (it is incomplete now). With best regards, Vitaly ^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2024-12-25 16:18 UTC | newest] Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2020-08-12 20:07 [PATCH 1/2] Make xact.h usable in frontend. Heikki Linnakangas <[email protected]> 2024-12-25 16:18 Re: An improvement of ProcessTwoPhaseBuffer logic Vitaly Davydov <[email protected]>
This inbox is served by agora; see mirroring instructions for how to clone and mirror all data and code used for this inbox