Hello!

I haven't read the thread, so, some parts may have already been discussed.

> SetHintBits(tuple, buffer, HEAP_XMIN_COMMITTED,
> HeapTupleHeaderGetRawXmax(tuple));

Should it be Xmin?

> PopActiveSnapshot();
> InvalidateCatalogSnapshot();

> /* See above. */
> Assert(!TransactionIdIsValid(MyProc->xmin));

I received some helpful feedback from Mathias on related task (CIC
snapshot rotation) - [0].
I applied proposed fixes at [1].

Main things we may apply here:

1) RotateSnapshot (preserves a valid xmin all the time)
2) SnapshotRotation (structure to track rotation frequency)
3) Xmin asserts done by injection points with ERROR attachment. It is
done that way because sometimes it is not possible to avoid getting a
snapshot due to some expressions/computed columns/etc.
4) Handling IsolationUsesXactSnapshot in a non-error way (just
disables rotation)
5) Add stress-tests form [2] and rotate snapshot every page (or some
other extreme value)

Also, seems like build_new_index may use new snapshot for each index
it builds (at least until CIC-related snapshot rotation is not in
core).

Regarding the auxiliary table, have you considered adding some
additional information to tuplesort (like xmin/lsn/tombstone) and
later use that during insertion to strip unneeded rows (for all rows
with the same key, take only "last" one)?

Best regards,
Mikhail.

[0]: 
https://www.postgresql.org/message-id/CAEze2WhwwAB_DVAWfunO%3D_1QZu-J%2BThbpVbvdoOyycswQETFfw%40mail.gmail.com
[1]: 
https://www.postgresql.org/message-id/CADzfLwV%2Bng11CQPju9HxJvK_rLAZ0_Zozno_%2B4Td26ZL1V_%3DrA%40mail.gmail.com
[2]: https://www.postgresql.org/message-id/[email protected]


Reply via email to