Skip to content

dsc: Add a command to recreate a region in place - #2073

Open
leftwo wants to merge 5 commits into
mainfrom
alan/dsc-recreate-region
Open

leftwo wants to merge 5 commits into
mainfrom
alan/dsc-recreate-region

Conversation

@leftwo

@leftwo leftwo commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

With this change we now have the ability in dsc to recreate a region in place.
"dsc cmd recreate -c N" replaces a stopped downstairs' region with a new,
empty region with the same geometry and a new UUID. Tests that use dsc
with reuse of a downstairs as a replacement can use this ability to make the
replacement "look like" what happens for real in the product where a
replacement downstairs is always fresh and new.

The new region is created next to the old one and renamed into place, so a
failed create leaves the old region alone. dsc refuses this action if the
downstairs is running or set to auto restart.

Because creating a region can take several seconds, or even minutes depending
on the size and other factors, we had to switch from a create and wait
model (which would timeout) to a submit the request, then poll for
completion. This avoids future test flakes that we would see otherwise.

This is the second in a stack (of 4?) PRs to update the test infra in preparation
for the min-quorum work coming soon behind it.

Claude has written a bunch of tests here and while I may not have bothered
to write them myself, the do add some value overall so while I'm not attached
to them, I'm also not in opposition to them. The open API doc also eats up
a bunch of lines, so the meat of this PR is not as many lines as what it
looks like at first glance.

@leftwo
leftwo requested a review from jmpesp November 5, 2026 18:34
@leftwo
leftwo added this pull request to stack #2075 November 5, 2026 19:43
@leftwo
leftwo force-pushed the alan/dsc-recreate-region branch from 78174b9 to 6e633ea Compare November 6, 2026 18:09
@leftwo
leftwo removed this pull request from stack #2075 November 6, 2026 18:35
@leftwo
leftwo changed the base branch from main to alan/dsc-monitor-wait November 6, 2026 18:37
@leftwo
leftwo added this pull request to stack #2077 November 6, 2026 18:39
Base automatically changed from alan/dsc-monitor-wait to main November 6, 2026 20:50
We now have the ability in dsc to recreate a region in place.
"dsc cmd recreate -c N" replaces a stopped downstairs' region with a
new, empty region with the same geometry and a new UUID.  Tests that
use dsc with reuse of a downstairs as a replacement can this ability
to make the replacement "look like" what happens for real in the
product where a replacement downstairs is always fresh and new.

The new region is created next to the old one and renamed into place,
so a failed create leaves the old region alone.  dsc refuses if the
downstairs is running or set to restart.
Creating a large region can take many minutes, longer than most
clients will wait.  POST /recreate/cid/{cid} will return once the
recreate has started.  The new GET /recreate/cid/{cid} returns
the creation status: idle, in progress, done with the new UUID,
or failed with the error.

The status is set to in progress before the POST returns, so a caller
polling after it can't see an earlier result.  If the recreate is
refused, for example because the downstairs is running, the status is
failed with the reason.  The status remains until the next recreate
starts.

The monitor creates the region in another task, so it keeps handling
commands.  It refuses a second recreate and ignores start and enable
restart until the recreate finishes.

dsc cmd recreate -c N will start a recreation and then polls the
status until the recreation finishes or errors and prints the result.

The fake downstairs used by the tests can now hold a create in
progress, and a new test checks what the monitor does while a recreate
is running.
@leftwo

leftwo commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

@claude review

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Findings marked 🟡 are optional suggestions and need no follow-up push.

Comment thread dsc/src/client.rs Resolved
Comment thread dsc/src/main.rs Resolved
Comment thread dsc/src/main.rs Outdated
Comment on lines +1487 to +1488
res = async { (&mut recreate.as_mut().unwrap().handle).await },
if recreate.is_some() =>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this is susceptible to futurelock, it's a &mut future in a tokio::select branch.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think this one was okay, as I don't believe we have other paths that need anything that this path has, but perhaps there are filesystem actions that could back things up.

Even so, it could be a setup that would trap future us where we did come in and update something in the loop that then allowed future lock to happen, so I've changed it around and we should be okay going forward.

Do a better job at reporting back errors when the region
replacement runs into trouble.
Change the way we spawn a task inside a select to avoid any
potential futurelock (PR comments)
@leftwo
leftwo requested a review from jmpesp November 10, 2026 18:38
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