Skip to content

Conversation

@isegall-da
Copy link
Contributor

@isegall-da isegall-da commented Jan 20, 2026

This factors out of the validator, to common, the key-value storage functionality from ValidatorInternalStore, and also applies some renaming to make it a more generic key-value and not specifically for "configurations".

Motivation:
Add a key-value store to Scan (specifically, in the near-term, to store progress of the bulk-storage dumps)

Pull Request Checklist

Cluster Testing

  • If a cluster test is required, comment /cluster_test on this PR to request it, and ping someone with access to the DA-internal system to approve it.
  • If a hard-migration test is required (from the latest release), comment /hdm_test on this PR to request it, and ping someone with access to the DA-internal system to approve it.

PR Guidelines

  • Include any change that might be observable by our partners or affect their deployment in the release notes.
  • Specify fixed issues with Fixes #n, and mention issues worked on using #n
  • Include a screenshot for frontend-related PRs - see README or use your favorite screenshot tool

Merge Guidelines

  • Make the git commit message look sensible when squash-merging on GitHub (most likely: just copy your PR description).

Signed-off-by: Itai Segall <itai.segall@digitalasset.com>
Signed-off-by: Itai Segall <itai.segall@digitalasset.com>
Signed-off-by: Itai Segall <itai.segall@digitalasset.com>
Signed-off-by: Itai Segall <itai.segall@digitalasset.com>
Signed-off-by: Itai Segall <itai.segall@digitalasset.com>
Signed-off-by: Itai Segall <itai.segall@digitalasset.com>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm thinking now that maybe this should just be added as another store in DbAppStore instead of having this class (and a similar one in Scan very soon). Thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand the suggestion, you want to add a generic def keyValues: KeyValueStore to trait AppStore?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Something like that. Mostly noticed that all other instantiations of StoreDescriptor are all in one place (e.g. for scan, it's in DbScanStore), so was wondering whether we want to add it somewhere that each app just needs to define the StoreDescriptor for it. But that whole setup with AcsStores, TxLogStores, etc is so complex as it is, that I'm no longer thinking this is a great idea...

Signed-off-by: Itai Segall <itai.segall@digitalasset.com>
Signed-off-by: Itai Segall <itai.segall@digitalasset.com>
Copy link
Contributor

@nicu-da nicu-da left a comment

Choose a reason for hiding this comment

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

Nice, thanks! This makes me wonder how do we treat such releases that make rollbacks not possible without a restore from backup though 🤔 Should we add a note to the release notes?

val jsonValue: Json = value.asJson

val action = sql"""INSERT INTO validator_internal_config (config_key, config_value, store_id)
val action = sql"""INSERT INTO key_value_store (key, value, store_id)
Copy link
Contributor

Choose a reason for hiding this comment

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

changing the table name, what about existing data? (does this matter for the validator store version?)

Copy link
Contributor

Choose a reason for hiding this comment

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

We're only renaming a table and some columns/constraints, that shouldn't affect existing data, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The table itself is also renamed accordingly in flyway, so data would be preserved

Copy link
Contributor

Choose a reason for hiding this comment

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

thanks missed that (flyway)

Copy link
Contributor

@ray-roestenburg-da ray-roestenburg-da left a comment

Choose a reason for hiding this comment

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

Thanks

Copy link
Contributor

@rautenrieth-da rautenrieth-da left a comment

Choose a reason for hiding this comment

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

Thanks!

val jsonValue: Json = value.asJson

val action = sql"""INSERT INTO validator_internal_config (config_key, config_value, store_id)
val action = sql"""INSERT INTO key_value_store (key, value, store_id)
Copy link
Contributor

Choose a reason for hiding this comment

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

We're only renaming a table and some columns/constraints, that shouldn't affect existing data, no?

val otherKey = "key2"
val otherValue = "jsonPayload2"

"set and get a payload successfully" in {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion for one more test: create two stores with different descriptors, check that they don't affect each others data.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍
(note that these tests are not new, it's just refactoring of the existing ones, separating the generic key-store ones from the ones specific for validator data, but I'll add a test nevertheless)

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand the suggestion, you want to add a generic def keyValues: KeyValueStore to trait AppStore?

@rautenrieth-da
Copy link
Contributor

This makes me wonder how do we treat such releases that make rollbacks not possible without a restore from backup though

Doesn't that apply to any change that adds a new flyway migration? We have 50 migrations already and haven't called them out in the release notes before. Shouldn't we just make it the default expectation that you can't downgrade to a previous release without restoring from backup?

@nicu-da
Copy link
Contributor

nicu-da commented Jan 21, 2026

This makes me wonder how do we treat such releases that make rollbacks not possible without a restore from backup though

Doesn't that apply to any change that adds a new flyway migration? We have 50 migrations already and haven't called them out in the release notes before. Shouldn't we just make it the default expectation that you can't downgrade to a previous release without restoring from backup?

Additions are not an issue for rollbacks, and i suspect most of our migrations are additions and not mutations/deletions. We have occasionally rolled back at least on our own nodes so I think we should start giving more awareness to these forward only changes.

@rautenrieth-da
Copy link
Contributor

Additions are not an issue for rollbacks

Hm, this line says we explicitly configure flyway to complain if the database contains future migrations (those that are applied but not yet known to the running application). Is that not preventing application startup?

If not then mentioning database schema changes in release notes could be useful. Maybe a general compatibility table with columns like (CN release version, CN database version, Canton version, Canton database/protocol version)?

Signed-off-by: Itai Segall <itai.segall@digitalasset.com>
@isegall-da
Copy link
Contributor Author

Hm, this line says we explicitly configure flyway to complain if the database contains future migrations

So we basically never allowed downgrade between versions that contain any flyway migration?

@nicu-da
Copy link
Contributor

nicu-da commented Jan 22, 2026

Hm, this line says we explicitly configure flyway to complain if the database contains future migrations

So we basically never allowed downgrade between versions that contain any flyway migration?

It does look like it. Not ideal

@isegall-da isegall-da merged commit ba16a10 into main Jan 23, 2026
62 checks passed
@isegall-da isegall-da deleted the isegall/kvstore branch January 23, 2026 21:44
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.

5 participants