-
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
Conversation
…es on tables that are not part of migrations
…ctName and then re-using the code to first check if it is leaf table else lookup
…ags storing list with leaf in msr directly
850a85b
to
ce05787
Compare
bf3e4e0
to
f09e16f
Compare
… msr new fields with nil etc..
yb-voyager/cmd/exportData.go
Outdated
} | ||
|
||
if len(lo.Keys(newLeafTables)) > 0 { | ||
utils.PrintAndLog("Detected new partition tables for the following partitioned tables. These will not be considered during migration:") |
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.
Should we prompt?
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.
Not sure if a prompt is required, I think there is nothing we want users to do here right? so this might just FYI?
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.
Went over it at a high level, looks good!
Will give it a more detailed look soon along with the tests.
… DDL changes on source, subsequent run with table-list/exclude-table-list flags. Some TODOs remaining to added assertions for
yb-voyager/cmd/exportData_test.go
Outdated
|
||
// getInitialTableList for subsequent run with start-clean false and basic without table-list flags so no guardrails | ||
startClean = false | ||
getInitialTableistAndAssertExpectedResult(t, expectedTableList, expectedPartitionsToRootMap) |
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.
you added a new partition leaf above. This should error out no?
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.
We are not errorring out in this case just reporting to the user that new leafs found for these root tables and these will not be considered during migration,
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.
Ticket for having a guardrail check during the ongoing live migration for new leaf tables #2356
…ls and new leafs addition. Added tests for subsequent run validating the guardrails of missing and extra tables and new leaf tables addition
…ion as a function variable to be able to override it in the test
…s by adding a new field in nameRegfor Sequences detemination
3ed77c3
to
b034db2
Compare
yb-voyager/cmd/exportData.go
Outdated
} else { | ||
tableList = fullTableList | ||
//this is only for filtering the non-leaf and non-root tables - the mid level partitioned table from fullTableList |
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.
To remove non-leaf and non-root, you're still calling addLeafPartitionsInTableList
? That sounds a bit weird. Does that function ignore all leafs, and then re-add them?
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.
addLeafPartitionsInTableList
has a boolean parameter addAllLeafPartitions
in case this is false, that function will consider that the table-list passed is already exhaustive with all the tables (root, middle partition, leaf partitions, so on..) and it will just do the filtering to remove the middle level partitions and just the keep the leaf and root tables in the list.
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: write a separate specific function to remove the non-leaf/non-root tables.
Add a TODO if defering.
yb-voyager/cmd/exportData_test.go
Outdated
// Tests the unknown table case by over ridding the utils.ErrExit function to assert the error msg | ||
func testUnknownTableCaseForTableListFlags(t *testing.T, expectedUnknownErrorMsg string) { | ||
previousFunction := utils.ErrExit | ||
//changing the error exit function to test the unknown table scenario |
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.
oo, this does not seem like the best way to do it. To be fair, it essentially is just like "mocking" a function, so it's okay, but I think the right way would be:
If we write our functions in a way such that they return a list of guardrail failures, then we can just assert that, instead of having to mocking the errExit function.
Is this too much work given our current state?
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.
It's not a lot of work. I think it's more of a choice between these ways -
- Either we directly display the problem/guardrail and error out
- Return as an error and then display it on the console eventually with the whole context.
e.g.
➜ yb-voyager export data ... --export-type snapshot-and-changes --table-list asdfa
migrationID: a1194e55-3d95-4d37-95e3-d5221eed976d
....
Unknown table names in the include list: [asdfa]
Valid table names are: [...]
➜ yb-voyager export data ... --export-type snapshot-and-changes --table-list asdfa
migrationID: a1194e55-3d95-4d37-95e3-d5221eed976d
...
error getting initial table list: error applying table list flags for current list and remove roots: error in apply table list filter on registered list for the flags in current run: Unknown table names in the include list: [asdfa]
Valid table names are: [...]
I think the first one is better, where we directly display the problem/guardrails because it's not an actual error per say.
Let me know what do you think?
} | ||
|
||
//Filtering the new leaf tables if present in filteredListWithoutRootTable as we have reported above | ||
if isNewLeafTable(t) { |
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.
Why/how would the new leaf appear in currentRunTableListFilteredViaFlags?
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.
While applying include/exclude flags, we also add leaf partitions in case only the root is passed in flags.The addLeafPartitions
function goes to db for that case
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.
LGTM! pls update the PR description to reflect error vs prompt and if any other changes
Describe the changes in this pull request
export data from source
we are now using the stored table list in MSRTableListExportedFromSource
andSourceExportedTableListWithLeafPartitions
based on the source type as for PostgreSQL source we allow filtering the leaf partitions as well so storing them in MSR.export data from target,
we use the stored table list in MSRTableListExportedFromSource
to populate the leaf partitions from the target for all the partitioned tables. We then store this information in theTargetExportedTableListWithLeafPartitions
for further runs to avoid fetching new leaf partitions from the target.table-list
andexclude-table-list
flags to check for any discrepancy between these on resumption and the initial lists.Unknown tables found
.Missing tables ...
/Extra tables found ...
than the initial list and command error out sayingRe-run with the table-list passed in the initial run
Describe if there are any user-facing changes
Yes, as mentioned above there will be user-facing changes for some guardrails around table-list etc.. now user won't be able to change the table-list during the live migration
Behaviour in these scenarios
With or without table-list flags: export data from source/target commands will be unaware of newly added tables and won’t consider it either during the run or re-run.
If a newly added table is passed through the table-list/exclude-table-list - commands error out saying unknown table, valid tables names are […].
With or without table-list flags:
-- During the run, export data from source/target commands will be unaware of newly added leaf tables and won’t consider it.
-- On re-run, export data from source/target commands will report to the user that new leaf tables are detected for partitioned tables with below msg -
If a new leaf partition table is passed through the table-list/exclude-table-list flags - commands error out saying unknown table; valid tables names are […].
In case some tables are removed from the initial list in resumption - commands will report that there is discrepancy found and error out as mentioned below
In case some tables are added from the initial list in resumption - commands will report that there is discrepancy found and error out as mentioned below
How was this pull request tested?
Added unit tests with test container PG source for various cases.
Does your PR have changes that can cause upgrade issues?