-
Notifications
You must be signed in to change notification settings - Fork 12
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
Restrict live migration to single table-list and added guardrails for that around table-list flags #2354
Open
priyanshi-yb
wants to merge
28
commits into
main
Choose a base branch
from
priyanshi/name-reg-table-name
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.
+1,113
−62
Open
Restrict live migration to single table-list and added guardrails for that around table-list flags #2354
Changes from 25 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
245034c
Initial changes for hanlding the table names for supporting ddl chang…
priyanshi-yb 28736f3
in case includetable list is not used then use stored list as include…
priyanshi-yb 0fe89a2
changed logic of getting getting registered list to first return obje…
priyanshi-yb 81ebdc7
minor fix
priyanshi-yb e07e69f
add leaf partititons in include list for guardrails
priyanshi-yb ce05787
handle the case where only subset of leaf partitions are passed in fl…
priyanshi-yb f275d35
fix the export data from target case after testing
priyanshi-yb f09e16f
minor cleanup
priyanshi-yb 65fd658
Report the new leaf tables added upfront on re-run in the command output
priyanshi-yb c760d92
minor cleanup
priyanshi-yb f8869de
Minor fix to handle upgrade and resumption in export data, hanlde the…
priyanshi-yb 5da3738
restructured the code in smaller re-usable functions for table-list area
priyanshi-yb 2d132cb
minor change
priyanshi-yb fa0370d
minor misss for first run in export data from target
priyanshi-yb 90e2dd7
added unit tests for fetchTablesNamesFromSourceAndFilterTableList
priyanshi-yb 36e02eb
fix git tag
priyanshi-yb d042d3d
clean db after each test
priyanshi-yb bdd9b39
test for the subsequent run basic
priyanshi-yb e64f29f
more tests on Subsequent run with basic start-clean true/false cases,…
priyanshi-yb b842a60
Restructured the code a bit to be able to add more tests for guardrai…
priyanshi-yb 25d97fc
Added Unknown table case as well, by changing the utils.ErrExit funct…
priyanshi-yb 0cd8597
Merge branch 'main' into priyanshi/name-reg-table-name
priyanshi-yb ccc7316
minor change
priyanshi-yb e4f8a89
minor change
priyanshi-yb b034db2
fixed the 'GetRegisteredTableList' function to return only table name…
priyanshi-yb 51db76b
minor miss
priyanshi-yb a61d355
some review comments
priyanshi-yb 0325e8b
minor comment
priyanshi-yb 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
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ package namereg | |
import ( | ||
"errors" | ||
"fmt" | ||
"slices" | ||
"strings" | ||
|
||
"github.com/samber/lo" | ||
|
@@ -68,6 +69,9 @@ type NameRegistry struct { | |
// Source replica has same table name list as original source. | ||
|
||
params NameRegistryParams | ||
|
||
SourceDBSequenceNames map[string][]string | ||
YBSequenceNames map[string][]string | ||
} | ||
|
||
func InitNameRegistry(params NameRegistryParams) error { | ||
|
@@ -148,6 +152,7 @@ func (reg *NameRegistry) registerSourceNames() (bool, error) { | |
reg.SourceDBType = reg.params.SourceDBType | ||
reg.initSourceDBSchemaNames() | ||
m := make(map[string][]string) | ||
m1 := make(map[string][]string) | ||
for _, schemaName := range reg.SourceDBSchemaNames { | ||
tableNames, err := reg.params.SDB.GetAllTableNamesRaw(schemaName) | ||
if err != nil { | ||
|
@@ -159,11 +164,46 @@ func (reg *NameRegistry) registerSourceNames() (bool, error) { | |
return false, fmt.Errorf("get all sequence names: %w", err) | ||
} | ||
m[schemaName] = append(m[schemaName], seqNames...) | ||
m1[schemaName] = append(m1[schemaName], seqNames...) | ||
} | ||
reg.SourceDBTableNames = m | ||
reg.SourceDBSequenceNames = m1 | ||
return true, nil | ||
} | ||
|
||
func (reg *NameRegistry) GetRegisteredTableList() ([]*sqlname.ObjectName, error) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add a comment here on why we implemented this (partitions) |
||
var res []*sqlname.ObjectName | ||
var m map[string][]string // Complete list of tables and sequences | ||
var sequencesMap map[string][]string // only sequence list | ||
var dbType string | ||
var defaultSchemaName string | ||
switch reg.params.Role { | ||
case SOURCE_DB_EXPORTER_ROLE, SOURCE_DB_IMPORTER_ROLE, SOURCE_REPLICA_DB_IMPORTER_ROLE: | ||
m = reg.SourceDBTableNames | ||
sequencesMap = reg.SourceDBSequenceNames | ||
dbType = reg.SourceDBType | ||
defaultSchemaName = reg.DefaultSourceDBSchemaName | ||
if reg.params.Role == SOURCE_REPLICA_DB_IMPORTER_ROLE { | ||
defaultSchemaName = reg.DefaultSourceReplicaDBSchemaName | ||
} | ||
case TARGET_DB_EXPORTER_FB_ROLE, TARGET_DB_EXPORTER_FF_ROLE, TARGET_DB_IMPORTER_ROLE: | ||
m = reg.YBTableNames | ||
sequencesMap = reg.YBSequenceNames | ||
dbType = constants.YUGABYTEDB | ||
defaultSchemaName = reg.DefaultYBSchemaName | ||
} | ||
for s, tables := range m { | ||
for _, t := range tables { | ||
if slices.Contains(sequencesMap[s], t) { | ||
//If its a sequence continue and not append in the registerd list | ||
continue | ||
} | ||
res = append(res, sqlname.NewObjectName(dbType, defaultSchemaName, s, t)) | ||
} | ||
} | ||
return res, nil | ||
} | ||
|
||
func (reg *NameRegistry) initSourceDBSchemaNames() { | ||
// source.Schema contains only one schema name for MySQL and Oracle; whereas | ||
// it contains a pipe separated list for postgres. | ||
|
@@ -191,6 +231,7 @@ func (reg *NameRegistry) registerYBNames() (bool, error) { | |
yb := reg.params.YBDB | ||
|
||
m := make(map[string][]string) | ||
m1 := make(map[string][]string) | ||
reg.DefaultYBSchemaName = reg.params.TargetDBSchema | ||
if reg.SourceDBTableNames != nil && reg.SourceDBType == constants.POSTGRESQL { | ||
reg.DefaultYBSchemaName = reg.DefaultSourceDBSchemaName | ||
|
@@ -212,8 +253,10 @@ func (reg *NameRegistry) registerYBNames() (bool, error) { | |
return false, fmt.Errorf("get all sequence names: %w", err) | ||
} | ||
m[schemaName] = append(m[schemaName], seqNames...) | ||
m1[schemaName] = append(m1[schemaName], seqNames...) | ||
} | ||
reg.YBTableNames = m | ||
reg.YBSequenceNames = m1 | ||
return true, nil | ||
} | ||
|
||
|
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.
nit:
minQuotedTableList
->minQuotedTableListWithRoots