-
Notifications
You must be signed in to change notification settings - Fork 465
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
storage/adapter: Opt-in migration of sources to the new table model #30483
Draft
jkosh44
wants to merge
39
commits into
MaterializeInc:main
Choose a base branch
from
jkosh44:source-table-migration
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
9870b80
Opt-in catalog migration for converting subsources to source tables
rjobanp f9ebeaf
Add migration logic for source statements
rjobanp 5825163
Rename the feature flag
rjobanp 51b1765
Add new table to audit log
rjobanp c486e12
Add platform check scenario to test migration
rjobanp d619d5b
Switch to using system vars instead of flags to allow console access …
rjobanp b12e394
Fixes to migration based on testing
rjobanp 0437619
Also test the migration in the legacy upgrade tests
rjobanp 55292a9
platform checks: unique source name
nrainer-materialize 70edead
Migration structure cleanup from feedback
rjobanp 8b343d4
Address more feedback; ensure new source name is unique
rjobanp 1fc1c64
Fix legacy-upgrade checks
rjobanp 20c1d39
Fixes caused by rebase on main
rjobanp 1c400f0
ci: print source table migration issues
nrainer-materialize bb51c06
migration tests: pg-cdc-old-syntax
nrainer-materialize ede1b97
migration tests: extract logic
nrainer-materialize d130b66
migration tests: improve verification
nrainer-materialize 2ec7de2
migration tests: mysql-cdc-old-syntax
nrainer-materialize 3968ff2
migration tests: testdrive-old-kafka-syntax
nrainer-materialize 97184a2
migration tests: improve output
nrainer-materialize 1a45397
migration tests: fixes
nrainer-materialize bd7286b
migration tests: fixes
nrainer-materialize 4c72ba8
Fix for mysql source being restarted after new table added
rjobanp acec835
Avoid needing to rewrite ids of dependent statements by changing the …
rjobanp 1c78f0f
Fix merge skew
jkosh44 e158d0e
Fix dependency tracking
jkosh44 b674f66
Fix lint
jkosh44 f724904
Fix some issues
jkosh44 6fb5019
Fix dependency tracking
jkosh44 d097a28
Fix merge skew
jkosh44 96cd8e0
Update test versions
jkosh44 1fa1454
More merge skew fixes
jkosh44 0195195
Update item sorting to only sort within item groups
jkosh44 3bc8a27
Experiment for migrate
jkosh44 5b26267
Fix migration idempotency
jkosh44 3f6c1b9
Fixup
jkosh44 2c8c23c
resolve merge conflicts
jkosh44 7b6be9d
Update versions
jkosh44 39434cd
Fix more merge skew
jkosh44 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,71 @@ | ||
# Copyright Materialize, Inc. and contributors. All rights reserved. | ||
# | ||
# Use of this software is governed by the Business Source License | ||
# included in the LICENSE file at the root of this repository. | ||
# | ||
# As of the Change Date specified in that file, in accordance with | ||
# the Business Source License, use of this software will be governed | ||
# by the Apache License, Version 2.0. | ||
|
||
"""Utilities for testing the source table migration""" | ||
from materialize.mz_version import MzVersion | ||
from materialize.mzcompose.composition import Composition | ||
|
||
|
||
def verify_sources_after_source_table_migration( | ||
c: Composition, file: str, fail: bool = False | ||
) -> None: | ||
source_names_rows = c.sql_query( | ||
"SELECT sm.name || '.' || src.name FROM mz_sources src INNER JOIN mz_schemas sm ON src.schema_id = sm.id WHERE src.id LIKE 'u%';" | ||
) | ||
source_names = [row[0] for row in source_names_rows] | ||
|
||
print(f"Sources created in {file} are: {source_names}") | ||
|
||
c.sql("SET statement_timeout = '20s'") | ||
|
||
for source_name in source_names: | ||
_verify_source(c, file, source_name, fail=fail) | ||
|
||
|
||
def _verify_source( | ||
c: Composition, file: str, source_name: str, fail: bool = False | ||
) -> None: | ||
try: | ||
print(f"Checking source: {source_name}") | ||
|
||
# must not crash | ||
statement = f"SELECT count(*) FROM {source_name};" | ||
print(statement) | ||
c.sql_query(statement) | ||
|
||
statement = f"SHOW CREATE SOURCE {source_name};" | ||
print(statement) | ||
result = c.sql_query(statement) | ||
sql = result[0][1] | ||
assert "FOR TABLE" not in sql, f"FOR TABLE found in: {sql}" | ||
assert "FOR ALL TABLES" not in sql, f"FOR ALL TABLES found in: {sql}" | ||
|
||
if not source_name.endswith("_progress"): | ||
assert "CREATE SUBSOURCE" not in sql, f"CREATE SUBSOURCE found in: {sql}" | ||
|
||
print("OK.") | ||
except Exception as e: | ||
print(f"source-table-migration issue in {file}: {str(e)}") | ||
|
||
if fail: | ||
raise e | ||
|
||
|
||
def check_source_table_migration_test_sensible() -> None: | ||
assert MzVersion.parse_cargo() < MzVersion.parse_mz( | ||
"v0.137.0" | ||
), "migration test probably no longer needed" | ||
|
||
|
||
def get_old_image_for_source_table_migration_test() -> str: | ||
return "materialize/materialized:v0.129.0" | ||
|
||
|
||
def get_new_image_for_source_table_migration_test() -> str | None: | ||
return None |
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.
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.
neat!