Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Replicated] crosscluster/logical: enable automatic bidi replication #225

Merged
merged 5 commits into from
Jan 17, 2025

Conversation

mohini-crl
Copy link
Owner

Replicated from original PR cockroachdb#138297

Original author: msbutler
Original creation date: 2025-01-06T15:51:16Z

Original reviewers: msbutler, jeffswenson

Original description:

This patch enables a user to create a bidirectional replication stream with one
command. When the user runs CREATE LOGICALLY REPLICATED TABLE tabB FROM tabA ON uriA WITH BIDIRECTIONAL ON uriB, the following will happen:

  • on cluster B, during job planning, construct the reverse stream cmd, while we
    still have access to original LDR cmd. This command will have the following
    form: CREATE LOGICAL REPLICATION STREAM FROM TABLE tabB ON 'uriB' INTO TABLE tabA WITH CURSOR = $1, PARENT = '{og job id}';
  • on cluster B, create table tabB and begin an offline scan, as normal
  • on cluster B, once the offline scan completes, but before tabB is published,
    set up the reverse stream from B to A at a cursor time after the initial scan
    completes but before the tabB has come online. This cursor time prevents data
    looping and ensures the replication of all future foreground writes.
  • on cluster B, steady state replication begins.

Epic: none

Release note (sql change): when a user runs CREATE LOGICALLY REPLICATED TABLE,
they must specify one of the following options:

  • UNIDIRECTIONAL: setups a unidirectional stream with fast initial scan
  • BIDIRECTIONAL ON {dest uri}: sets up a bidirectional stream from the original
    dest to the original source.

This patch introduces two options to CREATE LOGICALLY REPLICATED TABLES:
- UNIDIRECTIONAL: to specify a unidectional ldr stream with a fast offline scan
- BIDIRECTIONAL ON {uri}: which customers will use to set up a bidirectional
  stream with one command. The uri provided by the customer connects to the
source of the reverse stream, aka the destination of the main stream.

The PARENT option will be used internally to set up the reverse stream.
Specifically, when the destination sets up the reverse stream, it will pass its
jobID as the parent for the reverse stream, which the reverse stream will use
to prevent creating duplicate reverse streams and to configure a stream that
replicates from an offline source. Customers should not directly use it.

Epic: none

Release note: none
This destination will use this api to set up a reverse stream from a cursor.

Epic: none

Release note: none
For mysterious resons, the resolver cannot fetch offline descriptors unless the
mutable flag is passed.

Epic: none

Release note: none
This patch allows a user to create an LDR stream that replicates from an
offline table.

Epic: none

Release note: none
This patch enables a user to create a bidirectional replication stream with one
command. When the user runs `CREATE LOGICALLY REPLICATED TABLE tabB FROM tabA
ON uriA  WITH BIDIRECTIONAL ON uriB`, the following will happen:
- on cluster B, during job planning, construct the reverse stream cmd, while we
	still have access to original LDR cmd. This command will have the following
form: `CREATE LOGICAL REPLICATION STREAM FROM TABLE tabB ON 'uriB' INTO TABLE
tabA WITH CURSOR = $1, PARENT = '{og job id}';`
- on cluster B, create table tabB and begin an offline scan, as normal
- on cluster B, once the offline scan completes, but before tabB is published,
  set up the reverse stream from B to A at a cursor time after the initial scan
completes but before the tabB has come online. This cursor time prevents data
looping and ensures the replication of all future foreground writes.
- on cluster B, steady state replication begins.

Epic: none

Release note (sql change): when a user runs CREATE LOGICALLY REPLICATED TABLE,
they must specify one of the following options:
- UNIDIRECTIONAL: setups a unidirectional stream with fast initial scan
- BIDIRECTIONAL ON {dest uri}: sets up a bidirectional stream from the original
  dest to the original source.
@mohini-crl mohini-crl merged commit 016c422 into master Jan 17, 2025
1 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants