-
Notifications
You must be signed in to change notification settings - Fork 205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dpp 710 activate interning write side #11614
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 @@ | ||
e28b88accecead16dcd67becabf7ad230654b65f93c277e785ba77203c3db8b5 | ||
bd9ddd16ae4ecc09923215635442c83b7894e95d23203baccde6df27cb0ce2cf |
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
...ration/oracle-appendonly/V4__add_ledger_end_string_interning_columnt_to_parameters.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 @@ | ||
2131cf0ed208e236ebf0ae68c8153cb8080d3b133114902185393c2b34f0b45d |
5 changes: 5 additions & 0 deletions
5
...migration/oracle-appendonly/V4__add_ledger_end_string_interning_columnt_to_parameters.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,5 @@ | ||
-- Copyright (c) 2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. | ||
-- SPDX-License-Identifier: Apache-2.0 | ||
|
||
ALTER TABLE parameters | ||
ADD ledger_end_string_interning_id NUMBER; |
1 change: 1 addition & 0 deletions
1
.../src/main/resources/db/migration/postgres-appendonly/V113__enable_string_interning.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 @@ | ||
cc55310126bde9627d59698cee292506e4d80c8303f090ba8649c4f4c6e19fbc |
69 changes: 69 additions & 0 deletions
69
...api/src/main/resources/db/migration/postgres-appendonly/V113__enable_string_interning.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,69 @@ | ||
-- Copyright (c) 2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. | ||
-- SPDX-License-Identifier: Apache-2.0 | ||
|
||
-- add string_interning ledger-end tracking column to parameters | ||
ALTER TABLE parameters | ||
ADD COLUMN ledger_end_string_interning_id INTEGER; | ||
|
||
-- create temporary sequence to populate the string_interning table as migrating data | ||
CREATE SEQUENCE string_interning_seq_temp; | ||
-- add temporary index to aid string lookups as migrating data | ||
CREATE UNIQUE INDEX string_interning_external_string_temp_idx ON string_interning USING btree (external_string); | ||
|
||
-- add temporary migration function | ||
CREATE FUNCTION insert_to_string_interning(prefix TEXT, table_name TEXT, selector_expr TEXT) | ||
RETURNS void | ||
LANGUAGE plpgsql | ||
AS | ||
$$ | ||
BEGIN | ||
EXECUTE | ||
'INSERT INTO string_interning(internal_id, external_string) ' || | ||
'SELECT nextval(''string_interning_seq_temp''), id ' || | ||
'FROM (SELECT DISTINCT ''' || prefix || ''' || ' || selector_expr || ' id FROM ' || table_name || ') distinct_ids ' || | ||
'WHERE NOT EXISTS (SELECT 1 FROM string_interning WHERE external_string = distinct_ids.id)' || | ||
'AND id IS NOT NULL'; | ||
END | ||
$$; | ||
|
||
-- data migrations | ||
|
||
-- template_id | ||
SELECT insert_to_string_interning('t|', 'participant_events_create', 'template_id'); | ||
rautenrieth-da marked this conversation as resolved.
Show resolved
Hide resolved
|
||
SELECT insert_to_string_interning('t|', 'participant_events_divulgence', 'template_id'); | ||
SELECT insert_to_string_interning('t|', 'participant_events_consuming_exercise', 'template_id'); | ||
SELECT insert_to_string_interning('t|', 'participant_events_non_consuming_exercise', 'template_id'); | ||
|
||
-- party | ||
SELECT insert_to_string_interning('p|', 'participant_events_create', 'unnest(tree_event_witnesses)'); | ||
SELECT insert_to_string_interning('p|', 'participant_events_create', 'unnest(flat_event_witnesses)'); | ||
SELECT insert_to_string_interning('p|', 'participant_events_create', 'unnest(submitters)'); | ||
SELECT insert_to_string_interning('p|', 'participant_events_create', 'unnest(create_observers)'); | ||
SELECT insert_to_string_interning('p|', 'participant_events_create', 'unnest(create_signatories)'); | ||
|
||
SELECT insert_to_string_interning('p|', 'participant_events_divulgence', 'unnest(tree_event_witnesses)'); | ||
SELECT insert_to_string_interning('p|', 'participant_events_divulgence', 'unnest(submitters)'); | ||
|
||
SELECT insert_to_string_interning('p|', 'participant_events_consuming_exercise', 'unnest(tree_event_witnesses)'); | ||
SELECT insert_to_string_interning('p|', 'participant_events_consuming_exercise', 'unnest(flat_event_witnesses)'); | ||
SELECT insert_to_string_interning('p|', 'participant_events_consuming_exercise', 'unnest(submitters)'); | ||
SELECT insert_to_string_interning('p|', 'participant_events_consuming_exercise', 'unnest(exercise_actors)'); | ||
|
||
SELECT insert_to_string_interning('p|', 'participant_events_non_consuming_exercise', 'unnest(tree_event_witnesses)'); | ||
SELECT insert_to_string_interning('p|', 'participant_events_non_consuming_exercise', 'unnest(flat_event_witnesses)'); | ||
SELECT insert_to_string_interning('p|', 'participant_events_non_consuming_exercise', 'unnest(submitters)'); | ||
SELECT insert_to_string_interning('p|', 'participant_events_non_consuming_exercise', 'unnest(exercise_actors)'); | ||
|
||
SELECT insert_to_string_interning('p|', 'participant_command_completions', 'unnest(submitters)'); | ||
|
||
SELECT insert_to_string_interning('p|', 'party_entries', 'party'); | ||
|
||
-- fill ledger-end | ||
UPDATE parameters | ||
SET ledger_end_string_interning_id = (SELECT max(internal_id) FROM string_interning); | ||
|
||
-- remove temporary SQL objects | ||
DROP SEQUENCE string_interning_seq_temp; | ||
DROP INDEX string_interning_external_string_temp_idx; | ||
DROP FUNCTION insert_to_string_interning(TEXT, TEXT, TEXT); | ||
|
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
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this data migration is verified locally by ensuring it generates the same string_interning table as it was populated by the write side
for reviewers: this needs to confirm to logic in DbDtoToStringsForInterning.