Re: now() vs transaction_timestamp()
Amit Kapila <amit.kapila16@gmail.com>
From: Amit Kapila <amit.kapila16@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: konstantin knizhnik <k.knizhnik@postgrespro.ru>,
pgsql-hackers <pgsql-hackers@postgresql.org>, Robert Haas <robertmhaas@gmail.com>
Date: 2018-10-07T04:58:25Z
Lists: pgsql-hackers
On Sat, Oct 6, 2018 at 9:40 PM Tom Lane <tgl@sss.pgh.pa.us> wrote: > > Konstantin Knizhnik <k.knizhnik@postgrespro.ru> writes: > > On 06.10.2018 00:25, Tom Lane wrote: > >> So maybe the right answer is to change the parallel mode infrastructure > >> so it transmits xactStartTimestamp, making transaction_timestamp() > >> retroactively safe, and then in HEAD only we could re-mark now() as > >> safe. We might as well do the same for statement_timestamp as well. > > > Attached please find very small patch fixing the problem (propagating > > transaction and statement timestamps to workers). > > That's a bit too small ;-) ... one demonstrable problem with it is > that the parallel worker will report the wrong xactStartTimestamp > to pgstat_report_xact_timestamp(), since you aren't jamming the > transmitted value in soon enough. Also, I found that ParallelWorkerMain > executes at least two transactions before it ever gets to the "main" > transaction that does real work, and I didn't much care for the fact > that those were running with worker-local values of xactStartTimestamp > and stmtStartTimestamp. So I rearranged things a bit to ensure that > parallel workers wouldn't generate their own values for either > timestamp, and pushed it. > Currently, we serialize the other transaction related stuff via PARALLEL_KEY_TRANSACTION_STATE. However, this patch has serialized xact_ts via PARALLEL_KEY_FIXED which appears okay, but I think it would have been easier for future readers of the code if all the similar state variables have been serialized by using the same key. -- With Regards, Amit Kapila. EnterpriseDB: http://www.enterprisedb.com
Commits
-
Propagate xactStartTimestamp and stmtStartTimestamp to parallel workers.
- bdc2e7a19af7 9.6.11 landed
- 58454d0bb07c 10.6 landed
- 3c9dd963cec6 9.5.15 landed
- 6bf278df891d 11.0 landed
- 07ee62ce9e50 12.0 landed