Skip to content

Add explicit deployment state modes and optional DMS history - #7151

Merged
shreyas-goenka merged 52 commits into
mainfrom
shreyas-goenka_data/shreyas/statedb-modes
Oct 26, 2026
Merged

shreyas-goenka merged 52 commits into
mainfrom
shreyas-goenka_data/shreyas/statedb-modes

Conversation

@shreyas-goenka

@shreyas-goenka shreyas-goenka commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Changes

This PR adds modes to StateDB setting the stage for recording history in a best effort way. This supported is added via new mode (WritingFileWithHistoryEnforced) that'll be made the default for dpeloyment history in a followup PR.

Existing tests pass - purely refactor.

@github-actions github-actions Bot added the DABs DABs related issues label Oct 21, 2026
@eng-dev-ecosystem-bot

eng-dev-ecosystem-bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator

Integration test report

Commit: 1723931

Run: 39955943784

Env ✅​pass 🙈​skip Time
✅​ aws linux-2core-8gb 281 15 3:55
✅​ aws-windows-latest-4core-16gb 283 13 3:39
✅​ azure linux-2core-8gb 280 15 3:58
✅​ azure-windows-latest-4core-16gb 282 13 4:59
✅​ gcp linux-2core-8gb 281 15 4:02
✅​ gcp-windows-latest-4core-16gb 283 13 3:23
Top 3 slowest tests (at least 2 minutes):
duration env testname
4:53 azure-windows-latest-4core-16gb TestAccept
3:34 aws-windows-latest-4core-16gb TestAccept
3:18 gcp-windows-latest-4core-16gb TestAccept

// WritingFileWithHistoryEnforced writes state through WAL to resources.json and records DMS history.
// DMS errors and drain timeouts let the deployment continue.
// Persists deployment_history_best_effort to reject clients that cannot honor history recording.
WritingFileWithHistoryEnforced

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.

	// WritingDMS reads and writes resource state through DMS without creating a WAL.
	// DMS errors fail the deployment.
	WritingDMS

	// WritingFileWithHistory writes state through WAL to resources.json and records DMS history.
	// DMS errors and drain timeouts let the deployment continue.
	WritingFileWithHistory

	// WritingFileWithHistoryEnforced writes state through WAL to resources.json and records DMS history.
	// DMS errors and drain timeouts let the deployment continue.
	// Persists deployment_history_best_effort to reject clients that cannot honor history recording.
	WritingFileWithHistoryEnforced

a bit inconsistent, WritingFile and WritingDMS combined results in WritingFileWithHistoryEnforced, "DMS" & "History" both used interchangeably.

Perhaps

  • keep WritingDMS
  • WritingFileShadowDMSOptional # no feature
  • WritingFileShadowDMSRequired # with feature

I also wonder should we drop the last one for now and implement WritingFileShadowDMSOptional end to end?

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.

q: do both WritingFileWithHistory and WritingFileWithHistoryEnforced trigger migration?

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 also wonder should we drop the last one for now and implement WritingFileShadowDMSOptional end to end?

The only downside is we make the feature weaker since we can no longer guarentee history. Since I've already implemented this I'd be inclined to keep it, given it's the end state we are moving towards anyways.

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.

WritingFile and WritingDMS combined results in WritingFileWithHistoryEnforced

There's a qualitative difference. WritingDMS reads from DMS and treats it as SOT. WritingFileWithHistoryEnforced does not.

//
// DMS reads require a workspace client on ctx. DMS writes and history recording
// start after a version exists and InitializeOperationBuffer is called.
func (db *DeploymentState) Open(ctx context.Context, path string, mode Mode, withRecovery WithRecovery, dmsDeployment OpenDmsArgs) error {

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.

Previously there was only paved path for modes (start with reading then go into writing). Now you can open it in arbitrary mode, that makes it harder to reason. Can we drop mode from here and start with Reading always as before?

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.

By design I did not support a upgrade path for ReadingDMS -> WritingDMS. It just adds complexity (I did try it out). That's why Open takes the argument, to allow us to start at mode WritingDMS.

TBF we could fully cleanup WritingDMS but I'm inclined towards keeping it for now since it will make hte eventual switchover simpler.

We can continue to run local tests with WritingDMS as well.

ctx = cmdctx.SetWorkspaceClient(ctx, b.WorkspaceClient(ctx))
}
if err := b.DeploymentBundle.StateDB.Open(ctx, localPath, dstate.WithRecovery(false), dstate.WithWrite(false), dstate.WithDeploymentHistory(true), dstate.OpenDmsArgs{DeploymentID: dmsDeploymentID, LastVersionID: lastVersionID}); err != nil {
if err := b.DeploymentBundle.StateDB.Open(ctx, localPath, dstate.WritingDMS, dstate.WithRecovery(false), dstate.OpenDmsArgs{DeploymentID: dmsDeploymentID, LastVersionID: lastVersionID}); err != nil {

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.

How did dstate.WithWrite(false) got transformed into dstate.WritingDMS here?

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.

Because dstate.WithWrite(false) is not meaningful for DMS. It would actually require us to add a "upgrade path" for ReadingDMS. I figured the code is simpler to just always start at writing mode. It's a completely independent code path anyways.

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.

then enum value should be called ReadingWritingDMS perhaps?

@shreyas-goenka
shreyas-goenka added this pull request to the merge queue Oct 26, 2026
Merged via the queue into main with commit 4d88efe Oct 26, 2026
27 checks passed
@shreyas-goenka
shreyas-goenka deleted the shreyas-goenka_data/shreyas/statedb-modes branch October 26, 2026 10:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

DABs DABs related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants