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

kvserver: disconnect rangefeeds on AddSSTable #72724

Closed

Conversation

erikgrinaker
Copy link
Contributor

@erikgrinaker erikgrinaker commented Nov 13, 2021

This patch disconnects rangefeeds on AddSSTable application with
REASON_ADDSSTABLE. This allows consumers to reconnect and run a
catchup scan to see the new writes.

The rangefeed is only disconnected when WriteAtRequestTimestamp is
enabled for the AddSSTable request. Otherwise the SSTable may write
below the closed timestamp, and so a catchup scan may not see the
changes anyway.

Since we have to disconnect the rangefeed even for IngestAsWrites,
which does not produce a replicated AddSSTable result (there is no SST
to link), a new field ReplicatedEvalResult.DisconnectRangeFeed is
added as a general mechanism to disconnect the rangefeed. This is not
used elsewhere, to retain backwards compatibility with 21.2 followers,
but WriteAtRequestTimestamp requires a 22.1 MVCCAddSSTable version
gate and can therefore safely rely on this field.

Resolves #70434.

Release note: None

@erikgrinaker erikgrinaker self-assigned this Nov 13, 2021
@erikgrinaker erikgrinaker requested a review from a team November 13, 2021 12:49
@erikgrinaker erikgrinaker requested review from a team as code owners November 13, 2021 12:49
@erikgrinaker erikgrinaker requested review from msbutler and removed request for a team November 13, 2021 12:49
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@erikgrinaker erikgrinaker removed request for a team and msbutler November 13, 2021 12:49
Copy link
Member

@tbg tbg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only looked at last commit.

Reviewed 2 of 4 files at r1, 3 of 6 files at r2, 6 of 10 files at r3, 24 of 28 files at r4, 11 of 11 files at r5, all commit messages.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @ajwerner and @aliher1911)

@erikgrinaker
Copy link
Contributor Author

erikgrinaker commented Nov 22, 2021

One thing that bugs me about this is the potential for thrashing. During imports and such we'll often fire off lots of AddSSTable requests over a long period of time, and if there is an active rangefeed consumer it will presumably keep retrying and kicking off backfills, which will fail again on the next AddSSTable.

I suppose what saves us is that there shouldn't be any rangefeed consumers over these spans as the table is offline, at least not until we implement streaming cluster-to-cluster replication.

This patch disconnects rangefeeds on `AddSSTable` application with
`REASON_ADDSSTABLE`. This allows consumers to reconnect and run a
catchup scan to see the new writes.

The rangefeed is only disconnected when `WriteAtRequestTimestamp` is
enabled for the `AddSSTable` request. Otherwise the SSTable may write
below the closed timestamp, and so a catchup scan may not see the
changes anyway.

Since we have to disconnect the rangefeed even for `IngestAsWrites`,
which does not produce a replicated `AddSSTable` result (there is no SST
to link), a new field `ReplicatedEvalResult.DisconnectRangeFeed` is
added as a general mechanism to disconnect the rangefeed. This is not
used elsewhere, to retain backwards compatibility with 21.2 followers,
but `WriteAtRequestTimestamp` requires a 22.1 `MVCCAddSSTable` version
gate and can therefore safely rely on this field.

Release note: None
@erikgrinaker
Copy link
Contributor Author

I'm going to let this sit for a bit and see how much work it'd be to publish SSTs to the range feed instead, since that's the preferred long-term solution anyway. My hunch is that it won't take much.

@erikgrinaker
Copy link
Contributor Author

See #73487 for proper handling of AddSSTable in rangefeeds, which will likely make this PR obsolete.

craig bot pushed a commit that referenced this pull request Dec 7, 2021
73436: kvserver: add timeouts for rangefeed test cases r=tbg a=erikgrinaker

This splits out some test tweaks from #72724, since we're exploring alternative approaches for that PR and may abandon it.

Release note: None

Co-authored-by: Erik Grinaker <[email protected]>
@erikgrinaker
Copy link
Contributor Author

Closing in favor of #73487.

@erikgrinaker erikgrinaker deleted the addsstable-rangefeed branch February 14, 2022 12:15
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.

kvserver: rangefeed handling of AddSSTable
4 participants