Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

[TS | LIP-164000] Reset Sweep Progress #5277

Merged
merged 9 commits into from
Mar 3, 2021
Merged

Conversation

jeremyk-91
Copy link
Contributor

Goals (and why):

  • Have the ability to reset sweep progress. This may be useful to deal with circumstances where entries are written to the targeted sweep queue after the sweep timestamp has progressed past it - while the transaction in question will necessarily fail, there may still be cruft in the targeted sweep queue.

Implementation Description (bullets):

  • Add a config flag. If set, on startup does a CAS to 0 and doesn't perform targeted sweep. This is needed because a service has multiple nodes, but once the last node rolls, assuming it starts successfully, no one is running sweep and we CAS the progress to 0 -> we have 0 for all shards and strategies.

Testing (What was existing testing like? What have you done to improve it?): Added some unit tests.

Concerns (what feedback would you like?):

  • What happens if the number of shards in the config is not what's actually persisted in the DB? I believe we do this correctly, but worth a check.
  • Have I thought through the concurrency model (especially across multiple nodes) correctly? and/or, is this too heavy-handed?

Where should we start reviewing?: ShardProgress

Priority (whenever / two weeks / yesterday): this week

@jeremyk-91 jeremyk-91 requested a review from gmaretic February 23, 2021 22:22
@changelog-app
Copy link

changelog-app bot commented Feb 23, 2021

Generate changelog in changelog/@unreleased

Type

  • Feature
  • Improvement
  • Fix
  • Break
  • Deprecation
  • Manual task
  • Migration

Description

Targeted sweep progress may be reset with the resetTargetedSweepQueueProgressAndStopSweep flag in targeted sweep install configuration. This may be useful in cleaning up cruft in the targeted sweep queue that may have been written by failed transactions.

As the name suggests, this will prevent sweep from cleaning up old cells, so users should not run with this configuration in the steady state. If running your service in HA, once the last node rolls and reports that it has successfully reset the sweep progress table, we can be certain that progress has been reset to zero.

Check the box to generate changelog(s)

  • Generate changelog entry

Copy link
Contributor

@gmaretic gmaretic left a comment

Choose a reason for hiding this comment

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

It's fine, but I'm not really sure why we want to stop sweep in addition to resetting. Though it's a good forcing function to make people remove the flag so I guess that's the reason.

@@ -135,6 +135,32 @@ private long increaseValueFromToAtLeast(ShardAndStrategy shardAndStrategy, long
return currentValue;
}

public void resetProgressForShard(ShardAndStrategy shardAndStrategy) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Eh, not a fan of the code duplication, but it's different enough to make it awkward to reuse. We could just delete the entry to make this much simpler but I assume we want HA -- not that sweep will work if we don't have delete consistency anyway...

conservativeScheduler.scheduleBackgroundThreads();
thoroughScheduler.scheduleBackgroundThreads();
if (shouldResetAndStopSweep) {
log.warn("This AtlasDB node is operating in a mode where it is attempting to reset the progress of "
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this really what we want? We could just allow it to start sweeping. Also the nodes on old versions will still be attempting to sweep anyway

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Discussed offline: this centers around the behaviour of targeted sweep where nodes CAS the bound from (thing I read -> my progress) repeatedly. We need to wait for all nodes to report that they're done with this.

doThrow(new CheckAndSetException("sadness")).when(mockKvs).checkAndSet(any());
ShardProgress instrumentedProgress = new ShardProgress(mockKvs);

assertThatCode(() -> instrumentedProgress.resetProgressForShard(CONSERVATIVE_TEN))
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably want to verify that it only throws once the value actually repeats

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, I think this is tested by stopsTryingToResetIfSomeoneElseDid() above - in practice you could check the CheckAndSetException's actual values but we don't get that here because of mocks, so I don't see another way of easily doing this?

Copy link
Contributor

Choose a reason for hiding this comment

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

OH I meant just verify that the method was called 4 times

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added!

@gmaretic
Copy link
Contributor

Discussed offline: document why we need to stop running sweep and wait for all nodes to reset

@bulldozer-bot bulldozer-bot bot merged commit a6f4a1f into develop Mar 3, 2021
@bulldozer-bot bulldozer-bot bot deleted the jkong/oneshot-tasks branch March 3, 2021 13:00
@svc-autorelease
Copy link
Collaborator

Released 0.302.5

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants