Skip to content

Conversation

@kim
Copy link
Contributor

@kim kim commented Oct 27, 2025

So far, the --clear-database option to publish has simply dropped
and then re-created the database (if it did exist).

This will no longer work when databases can have "children": because
dropping and re-creating is not atomic, children would either become
orphans, or be dropped as well.

To solve this, reset_database is introduced as a separate action that:

  • shuts down all replicas
  • if a program_bytes is supplied, replaces the database's initial
    program
  • if a host_type is supplied, replaces the database's host type
  • starts num_replicas or the previous number of replicas, which
    initialize themselves as normal

As this could be its own CLI command, the action is provided as its own
API endpoint (undocumented).

However, since publish has no way of knowing whether the database it
operates on actually exists, the publish_database handler will just
invoke the reset_database handler if clear=true and the database
exists, and return its result. This is to avoid starting the transfer of
the program in the request body, only to receive a redirect.

Some refactoring was necessary to dissect and understand the flow.

API and ABI breaking changes

Introduces a new, undocumented API endpoint.
We may want to nest it under /unstable.

Expected complexity level and risk

2

Testing

From the outside, the observed behavior should be as before,
so smoketests should cover it.

@kim kim requested review from Shubham8287 and gefjon October 27, 2025 15:55
@kim kim marked this pull request as ready for review October 27, 2025 15:55
@bfops bfops added the release-any To be landed in any release window label Oct 27, 2025
@kim kim changed the title Reset database [teams 1/5] Reset database Oct 29, 2025
Copy link
Contributor

@cloutiertyler cloutiertyler left a comment

Choose a reason for hiding this comment

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

Code owned files LGTM

So far, the `--clear-database` option to `publish` has simply dropped
and then re-created the database (if it did exist).

This will no longer work when databases can have "children": because
dropping and re-creating is not atomic, children would either become
orphans, or be dropped as well.

To solve this, `reset_database` is introduced as a separate action that:

- shuts down all replicas
- if a `program_bytes` is supplied, replaces the database's initial
  program
- if a `host_type` is supplied, replaces the database's host type
- starts `num_replicas` or the previous number of replicas, which
  initialize themselves as normal

As this could be its own CLI command, the action is provided as its own
API endpoint (undocumented).

However, since `publish` has no way of knowing whether the database it
operates on actually exists, the `publish_database` handler will just
invoke the `reset_database` handler if `clear=true` and the database
exists, and return its result. This is to avoid starting the transfer of
the program in the request body, only to receive a redirect.

Some refactoring was necessary to dissect and understand the flow.
@kim kim force-pushed the kim/reset-database branch from 624d9fc to e55816e Compare November 5, 2025 09:31
@kim kim enabled auto-merge November 5, 2025 09:35
@kim kim added this pull request to the merge queue Nov 5, 2025
Merged via the queue into master with commit 5c42b09 Nov 5, 2025
32 of 36 checks passed
@kim kim deleted the kim/reset-database branch November 5, 2025 11:58
@bfops bfops restored the kim/reset-database branch November 5, 2025 19:10
bfops added a commit that referenced this pull request Nov 5, 2025
github-merge-queue bot pushed a commit that referenced this pull request Nov 5, 2025
# Description of Changes

This reverts commit #3496.

# API and ABI breaking changes

Technically maybe yes? But definitely nothing is using the new code yet.

# Expected complexity level and risk

1

# Testing

CI only

Co-authored-by: Zeke Foppa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-any To be landed in any release window

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants