2.25.1.0-b264
tagged this
30 Jan 10:14
Summary: 17c2711109b63125d34caa4d781b33b7b4929167/D38542 introduced support for exporting and setting transaction snapshots in YSQL. The exported metadata is stored in the memory of the exporting tserver (inside `PgTxnSnapshotManager`) and needs to be cleaned up when the exporting transaction ends. Reasons for Cleanup: # Redundant Metadata Removal. # PostgreSQL Compatibility: In PostgreSQL, exported snapshots are only valid while the exporting transaction is alive. Once the exporting transaction ends, importing these snapshots is disallowed. YugabyteDB aims to enforce the same constraint by promptly cleaning up metadata after the exporting transaction terminates. A Transaction can end in the following ways: # Graceful Termniation ## Transaction Commits or Aborts ## Session ends gracefully # Ungraceful Termination ## Session ends ungracefully ## Exporting Tserver crashes ## Entire Cluster goes down When a transaction commits or aborts, PostgreSQL calls the `AtEOXact_Snapshot` function at the end of the transaction. In this function, a call is made to `PgTxnManager` to check for exported snapshots. If an exported snapshot exists, an RPC call is sent to the local tserver to erase the snapshots stored against this particular `session_id`, hence cleaning up all the stored snapshots of this session. When a session ends (gracefully or ungracefully), corresponding `PgClientSession` object is shutdown and cleaned up by the `PgClientService` in the method `CheckExpiredSessions`, for all the expired sessions we call `UnregisterAll` method of `PgTxnSnapshotManager` which cleans up the stored snapshots against this session (this was introduced in 17c2711109b63125d34caa4d781b33b7b4929167/D38542). When exporting tserver crashes, snapshot data automatically becomes unavailable as it was stored in tserver's memory only. **Upgrade/Rollback safety:** This revision is part of a new feature whose syntax is not currently used by any user. It introduces a new set of RPCs and messages, which will only be utilized when the new syntax is invoked. JIRA: DB-13046 Test Plan: ./yb_build.sh --cxx-test pgwrapper_pg_export_snapshot-test --gtest_filter "PgExportSnapshotTest.*" Reviewers: hsunder, skumar, pjain, patnaik.balivada, dmitry, stiwary Reviewed By: dmitry Subscribers: yql, ybase Differential Revision: https://phorge.dev.yugabyte.com/D39556