2.25.1.0-b307
tagged this
06 Feb 10:59
Summary: This revision introduces support for snapshot options in replication slot creation with the following options: - **USE_SNAPSHOT** - **EXPORT_SNAPSHOT** **Overview** When a replication slot is created with `USE_SNAPSHOT`, `consistent_snapshot_time` is fetched from the CDC service and set for the current session using the same API calls used by `SET TRANSACTION SNAPSHOT`. For `EXPORT_SNAPSHOT`, this `consistent_snapshot_time` is used to export the snapshot, similar to `pg_export_snapshot()`. However, instead of the `read_time` typically picked in the tserver as with `pg_export_snapshot()`, this `consistent_snapshot_time` provided by the CDC service is directly set as the `read_time` associated and stored with the snapshot. Implementation Details Commit 17c2711109b63125d34caa4d781b33b7b4929167 / D38542 introduced support for `pg_export_snapshot` and `SET TRANSACTION SNAPSHOT` in YB. This revision builds on those APIs to support the above-mentioned snapshot options. For both options, a `consistent_snapshot_time` is fetched from the CDC service while creating the replication slot. This is a HybridTime (not ReadHybridTime). Both `USE_SNAPSHOT` and `EXPORT_SNAPSHOT` use this HybridTime for setting and exporting the snapshot, respectively. **USE_SNAPSHOT** - When this option is provided, a ReadHybridTime (constructed from the single HybridTime `consistent_snapshot_time`) is sent to the tserver via the `ImportTxnSnapshot` RPC. - A new field, `cdc_snapshot_read_time`, is introduced in `PgImportTxnSnapshotRequestPB` to carry this timestamp. - The rest of the flow remains the same as `SET TRANSACTION SNAPSHOT`, except that the read time is directly taken from the CDC-provided `consistent_snapshot_time` instead of stored `read_time` against specified snapshot ID. **EXPORT_SNAPSHOT** - A new field, `cdc_snapshot_read_time`, is added to `PgExportTxnSnapshotRequestPB` and sent to the tserver via the `ExportTxnSnapshot` RPC. - This value is then stored as the `read_time` for the snapshot, and a new snapshot ID is generated. **Upgrade/Rollback safety:** This revision is part of a new feature whose syntax is not currently used by any user and guarded by a preview flag. It introduces new fields in already existing messages, which will only be utilized when the new syntax is invoked. JIRA: DB-13622 Test Plan: Jenkins: urgent ./yb_build.sh --java-test 'org.yb.pgsql.TestPgReplicationSlotSnapshotAction' ./yb_build.sh --cxx-test integration-tests_cdcsdk_consistent_snapshot-test --gtest_filter CDCSDKConsistentSnapshotTest.TestCreateReplicationSlotExportSnapshot ./yb_build.sh --cxx-test pgwrapper_pg_export_snapshot-test --gtest_filter "PgExportSnapshotTest.*" Reviewers: skumar, siddharth.shah, pjain, patnaik.balivada, stiwary, sumukh.phalgaonkar, hsunder, dmitry, xCluster Reviewed By: stiwary Subscribers: yql, ybase, ycdcxcluster, svc_phabricator Differential Revision: https://phorge.dev.yugabyte.com/D39355