-
Notifications
You must be signed in to change notification settings - Fork 206
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DPP-460 Parameter storage consolidation (#10472)
* Refactor ParameterStorageBackend - a single method for atomic ledger initialization - a single method to look up the ledger end changelog_begin changelog_end * Add a test * Fix reading event sequential ids * Remove debug statements * Allow ledgerEnd on an empty database * Initialization is not safe to call concurrently * Remove leftovers from isolation level change * Use unit return type for initialization methods * Allow getParticipantId on an empty database * Use exceptions instead of a return type ADT * Don't use Try for initialization * Clean up parameters table * Simplify parameter storage api * Address review suggestion * Address review comment * Address review comment * Prefer ledger id over participant id mismatch * Address review comment * Move type definition * Remove useleess new keyword * Renove unused import * Inline result mapping * Fix reporting of mismatching participantId
- Loading branch information
1 parent
569612a
commit 121047e
Showing
24 changed files
with
571 additions
and
362 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...n-api/src/main/resources/db/migration/h2database-appendonly/V1__Append_only_schema.sha256
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
e560dcc7af3b3b333a3d61668c351c7c1a1a0ac088bf83b59e0b4699a8073951 | ||
aae0b43e4735b3ffbdb782a61bad75f741c58a282327f3d3e18b0e41da5c69f6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ation-api/src/main/resources/db/migration/oracle-appendonly/V1__Append_only_schema.sha256
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
16adf83956d0f884d1d8886f317b3c0929839a9b0c385b5cb40c6e42cf328ef4 | ||
b5e44d2e0e0135b3b41d14ff9cde16300e58bdc7ef025c964a2d24e0da767ff2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...src/main/resources/db/migration/postgres-appendonly/V107__parameters_table_cleanup.sha256
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
77f0bfc35c00dc63e12d49256d267da19a36ca723d57a2949eae8331c52ff744 |
27 changes: 27 additions & 0 deletions
27
...pi/src/main/resources/db/migration/postgres-appendonly/V107__parameters_table_cleanup.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
-- Copyright (c) 2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. | ||
-- SPDX-License-Identifier: Apache-2.0 | ||
|
||
|
||
--------------------------------------------------------------------------------------------------- | ||
-- V107: Parameter table cleanup | ||
-- | ||
-- This migration makes sure the two following invariants hold: | ||
-- - The ledger_id and participant_id columns are always defined at the same time. I.e., either | ||
-- the table is empty, or both are defined. | ||
-- - The ledger_end and ledger_end_sequential_id are always defined at the same time. I.e., either | ||
-- both are NULL, or both are defined. | ||
-- Additionally, it removes unused columns. | ||
--------------------------------------------------------------------------------------------------- | ||
|
||
|
||
-- It is in theory possible that the participant_id column contains a NULL value. | ||
-- This should only happen if the first-time database initialization failed half-way between writing the | ||
-- ledger_id and participant_id. In this case, we would ask the operator to re-create or manually edit the database. | ||
ALTER TABLE parameters ALTER COLUMN participant_id SET NOT NULL; | ||
|
||
-- This should only apply when a database was migrated to the append-only schema, where the database contained some | ||
-- state updates (e.g., party allocations), but no events (i.e., no transactions). | ||
UPDATE parameters SET ledger_end_sequential_id = 0 WHERE ledger_end_sequential_id IS NULL AND ledger_end IS NOT NULL; | ||
|
||
-- This column is not needed anymore. | ||
ALTER TABLE parameters DROP COLUMN external_ledger_end; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.