Repository navigation
Conversation
…n, CASCADE keeps detached tables
The switchover fences writes by demoting the old primary's tables to read-only replicas in place. Only an Internal ModifyScheme could do that, and the only client that forwards one is the legacy MsgBus SchemeOperation service, so the tool needed `ydbd db schema exec`. ALTER TABLE <t> SET (REPLICATION_MODE = READ_ONLY | NONE, REPLICATION_CONSISTENCY_LEVEL = ROW | GLOBAL) replaces it. A new TModifyScheme.AllowReplicationModeChange stands in for Internal on this path and SchemeShard honours it only for a real cluster administrator, the same rule index implementation table alters already use. The demote also sets ImportState = IMPORTED and the consistency level, both of which the replication's attach path requires of a table it did not create, and applies to the implementation tables of synchronous and unique indexes.
Contributor
|
🔴 Unable to merge your PR into the base branch. Please rebase or merge it with the base branch. |
Member
Author
|
Superseded. Its two halves have gone separate ways:
This branch is also on a stale base and still carries the CASCADE change that was withdrawn in #59278. Closing. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changelog entry
Everything from #59171, and additionally:
ALTER TABLE <table> SET (REPLICATION_MODE = READ_ONLY | NONE, REPLICATION_CONSISTENCY_LEVEL = ROW | GLOBAL)turns an existing table into a read-only async-replication replica and back, for a cluster administrator. It is the write fence of a manual replication switchover, which no longer needs the legacyydbd db schema execservice.Description for reviewers
Stacked on #59171 (same three commits) with one commit on top. Review that PR first; this one only replaces how the switchover fences writes.
Why. A switchover demotes the old primary's tables to read-only replicas in place. SchemeShard already does exactly that, but only for an
InternalModifyScheme(schemeshard_info_types.cpprejects replica mode from a plain alter), and the only client that forwards a rawModifySchemeis the legacy MsgBusSchemeOperationcall. So #59171's tool needs the legacy gRPC service enabled on a node of each cluster. This PR gives the operation a supported door.What the statement does.
ALTER TABLE t SET (REPLICATION_MODE = READ_ONLY)setsReplicationConfig { Mode: READ_ONLY, ConsistencyLevel: ROW, ImportState: IMPORTED }on the table and, in the same operation, on the implementation tables of its synchronous and unique indexes, which are independent replication targets.NONEreverses it.IMPORTEDis what the replication's attach path requires of a table it did not create, and the consistency level has to be the one that replication's own configuration asks for, or itsCheckReplicationConfigrefuses the table (dst_creator.cpp) — henceREPLICATION_CONSISTENCY_LEVEL = GLOBALfor a globally consistent one;ROWis the default, and the setting is rejected withoutREPLICATION_MODE.Authorization. A new
TModifyScheme.AllowReplicationModeChangereplaces theInternalflag for this path, and SchemeShard honours it only for a real cluster administrator:IsAdministrator(...) && !AdministrationAllowedSIDs.empty(), the same rule the index-implementation-table alter already uses, so "all users are admins by default" does not grant it. A non-administrator getsStatusAccessDeniedwith a message naming the requirement. The flag is not reachable from the publicAlterTableRequest, which has no replication field; KQP builds the scheme transaction for this one setting.Where it is plumbed. Translator (both settings in the
ALTER TABLE ... SETallow-list, create-time andRESETrejected), KQP type annotation and exec (READ_ONLY/NONE, anything else is an error), gateway (builds theTModifySchemedirectly, like the local bloom filter index does), alter-kind classifier, SchemeShard (the admin gate plus propagation into index implementation tables).Tool.
fence,rollbackand thepromotefallback now issue the statement; the stale index changefeed is dropped through the Table API addressed by the index path, as the replication controller itself does.ydbdis left only for a read-onlydb schema describe. A--tokenoption (orYDB_TOKEN) carries the administrator token to both clusters and to the CLI.Tests: 5 parser cases in
SqlParsingOnly, andKqpScheme::AlterTableReplicationMode— administrator succeeds, non-administrator is denied, unknown values rejected, base and index implementation tables demoted with the right consistency level, writes rejected and reads served, back to writable. The tool's rehearsal was run end to end on a sandbox cluster pair with an administrator SID.