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

storage: Avoid adding all replicas at once in RelocateRange #29684

Merged
merged 2 commits into from
Sep 20, 2018

Conversation

a-robinson
Copy link
Contributor

Does a more gradual process of adding one replica then removing one
until all the desired changes have been made, using the existing
allocator code to do so in a reasonable order.

Fixes #29130

Release note: None


This is still a work-in-progress in the sense that it isn't really usable from the SQL code yet, since I just implemented it as a method on Store. If the approach looks reasonable, though, it can be converted it into an Admin API method.

@a-robinson a-robinson requested review from benesch and a team September 6, 2018 22:18
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Contributor

@benesch benesch left a comment

Choose a reason for hiding this comment

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

This basically LGTM. Let's make it an admin request and call it a day! 🎉 🎉 🎉

Reviewed 3 of 3 files at r1.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained

@a-robinson
Copy link
Contributor Author

This is ready for final review now, @benesch. Thanks in advance!

@a-robinson a-robinson changed the title WIP: storage: Avoid adding all replicas at once in RelocateRange storage: Avoid adding all replicas at once in RelocateRange Sep 14, 2018
Copy link
Contributor

@benesch benesch left a comment

Choose a reason for hiding this comment

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

Awesome! :lgtm:

Reviewed 14 of 14 files at r2.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale)

@a-robinson
Copy link
Contributor Author

Ugh, a sql logictest is now getting really finicky because the order of the replicas as specified in the RelocateRange command is no longer guaranteed to be the same as the order in the ReplicaDescriptor afterwards. I'm not sure it's even deterministic, so I may have to tweak that test somewhat meaningfully. Working on it.

@a-robinson
Copy link
Contributor Author

@jordanlewis can you take a quick look at the new first commit? Commit message copied here for convenience:


sql: Sort replicas in crdb_internal.ranges table by store ID

This matches the behavior of SHOW RANGES, and is the only way for the
replicas to be meaningfully ordered in a consistent way. It's odd that
the order doesn't even match the order in which the replicas are added.
For example, I could see this sequence in the logs for a range:

Starting replicas: [s4]
Adding s1 results in: [s4,s1]
Adding s2 results in: [s4,s1,s2]
Removing s4 results in: [s2,s1]

Release note (sql change): The entries in the replicas array column of
the crdb_internal.ranges virtual table are now always sorted by store
ID.

This matches the behavior of `SHOW RANGES`, and is the only way for the
replicas to be meaningfully ordered in a consistent way. It's odd that
the order doesn't even match the order in which the replicas are added.
For example, I could see this sequence in the logs for a range:

Starting replicas: [s4]
Adding s1 results in: [s4,s1]
Adding s2 results in: [s4,s1,s2]
Removing s4 results in: [s2,s1]

Release note (sql change): The entries in the replicas array column of
the crdb_internal.ranges virtual table are now always sorted by store
ID.
@a-robinson a-robinson force-pushed the store-rebalance2 branch 2 times, most recently from 7692de0 to 7c66418 Compare September 19, 2018 22:27
And convert it to an Admin command, AdminRelocateRange, as was required
to both let RelocateRange access the local store's resources while still
making it callable from the sql package.

It now does a more gradual process of adding one replica then removing
one until all the desired changes have been made, using the existing
allocator code to do so in a reasonable order.

Fixes cockroachdb#29130

Release note (sql change): The EXPERIMENTAL_RELOCATE statement no longer
temporarily increases the number of replicas in a range more than one
above the range's replication factor, preventing rare edge cases of
unavailability.
Copy link
Contributor

@benesch benesch left a comment

Choose a reason for hiding this comment

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

If you'll accept my review in place of @jordanlewis's: LGTM!

@a-robinson
Copy link
Contributor Author

bors r+

@craig
Copy link
Contributor

craig bot commented Sep 20, 2018

Build failed

@a-robinson
Copy link
Contributor Author

That's a new one to me:

[Resolving artifact dependencies] Failed to resolve artifact dependency <Cockroach / Unit Tests / Build Test Binary, build #31334 [id 917058]>: No files matched for patterns "cockroach" from <Cockroach / Unit Tests / Build Test Binary, build #31334 [id 917058]> (jetbrains.buildServer.artifacts.impl.SourcePathAwareResolvingFailedException)

bors r+

@craig
Copy link
Contributor

craig bot commented Sep 20, 2018

Build failed

@a-robinson
Copy link
Contributor Author

Ah, it's from the recent go-test-teamcity update (cockroachdb/go-test-teamcity#9). I'll wait until that's resolved (cockroachdb/go-test-teamcity#10).

@a-robinson
Copy link
Contributor Author

Retrying after merging cockroachdb/go-test-teamcity#10

bors r+

craig bot pushed a commit that referenced this pull request Sep 20, 2018
29684: storage: Avoid adding all replicas at once in RelocateRange r=a-robinson a=a-robinson

Does a more gradual process of adding one replica then removing one
until all the desired changes have been made, using the existing
allocator code to do so in a reasonable order.

Fixes #29130

Release note: None

-------------------

This is still a work-in-progress in the sense that it isn't really usable from the SQL code yet, since I just implemented it as a method on `Store`. If the approach looks reasonable, though, it can be converted it into an Admin API method.

Co-authored-by: Alex Robinson <alexdwanerobinson@gmail.com>
@craig
Copy link
Contributor

craig bot commented Sep 20, 2018

Build succeeded

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.

4 participants