-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BACKPORT 2.16.2][#16147] CDCSDK: Correctly set cdc_sdk_min_checkpoin…
…t_op_id to -1.-1 in upgrade scenarios Summary: Orginal commit: 8950c7b / D23283 If a cluster is upgraded from any version lesser than 2.14 to 2.14 or greater there is an issue with the initialisation of CDCSDK checkpoint per tablet. The value is initialised from the "cdc_sdk_min_checkpoint_op_id" field of raft superblock. In cases for tablets created before the upgrade, after the update this value defaults to OpId() (term: 0, index: 0). This has side-effects since if this checkpoint has any other value than -1.-1 we assume CDC has been enabled for the tablet. Through a previous fix(https://phabricator.dev.yugabyte.com/D22998), if the supeblock does not have "cdc_sdk_min_checkpoint_op_id" set, we will manually set it to -1.-1. But another scenario was missed. To give an example, If the cluster already in a version where the "cdc_sdk_min_checkpoint_op_id" was added (2.14 >), but below a version with the fix (2.14.7), the cluster would retain "cdc_sdk_min_checkpoint_op_id" as 0.0, again causing unnecessary intent retention after restarts. We now have introduced a new boolean field to the raft superblock: 'is_under_cdc_sdk_replication'. This new field will be set to true, if we ever set the 'cdc_sdk_min_checkpoint_op_id' to a valid OpId as part of CDC's logic. During tablet bootstrap, If this field is false, and we see the checkpoint is 0.0, we will infer that this was a upgrade scenario as described before and reset "cdc_sdk_min_checkpoint_op_id" to -1.-1. There however reamins one small window where the checkpoint could be legitimately set to 0.0, but the 'is_under_cdc_sdk_replication' field would be unset. This is if the cluster was in a version supporting CDC, but in a version without this fix, and there was an ongoing CDC snapshot process. The first step of the snapshot process sets the checkpoint to 0.0, and then an immediate RPC set's it to something higher (based on GetLastReplicatedData). If between these calls, there is a rolling upgrade, according to the fix, we will reset 'cdc_sdk_min_checkpoint_op_id' to -1.-1 which would be wrong. We will document that rolling upgrades should not be run during the CDC snapshot process. Also, we have now added a ctest: TestCheckPointWithNoCDCStream, which asserts that 'cdc_sdk_min_checkpoint_op_id' is set to -1.-1 in cases without CDC. Test Plan: Jenkins: urgent ybd --cxx-test cdcsdk_ysql-test --gtest_filter CDCSDKYsqlTest.TestCheckPointWithNoCDCStream ybd --cxx-test cdcsdk_ysql-test --gtest_filter CDCSDKYsqlTest.TestIsUnderCDCSDKReplicationField Reviewers: skumar Reviewed By: skumar Subscribers: ycdcxcluster Differential Revision: https://phabricator.dev.yugabyte.com/D23325
- Loading branch information
Adithya Bharadwaj
committed
Mar 4, 2023
1 parent
b101372
commit c84fd01
Showing
6 changed files
with
140 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters