Skip to content
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

Refactor migration assessment codepath: flatten reported issues #2153

Merged
merged 16 commits into from
Jan 8, 2025

Conversation

sanyamsinghal
Copy link
Collaborator

@sanyamsinghal sanyamsinghal commented Jan 6, 2025

Describe the changes in this pull request

  • Temporarily added new code to assessMigrationCommandV2.go
  • These functions will replace the existing codepath after UI updates are implemented.

Fixes: DB-14718, DB-14709, DB-14710, DB-14711, DB-14712, DB-14713, DB-14714, DB-14715

Sample of the how/what all info is stored in the AssessmentIssue struct

AssessmentIssue[0] = (cmd.AssessmentIssue) {
 Category: (string) (len=7) "feature",
 CategoryDescription: (string) (len=80) "Features of the source database that are not supported on the target YugabyteDB.",
 TypeName: (string) (len=24) "UNSUPPORTED_INDEX_METHOD",
 TypeDescription: (string) "",
 Impact: (string) "",
 ObjectType: (string) (len=5) "INDEX",
 ObjectName: (string) (len=46) "idx_box_data ON public.mixed_data_types_table1",
 SqlStatement: (string) (len=82) "CREATE INDEX idx_box_data ON public.mixed_data_types_table1 USING gist (box_data);",
 DocsLink: (string) (len=126) "https://docs.yugabyte.com/preview/yugabyte-voyager/known-issues/postgresql/#gist-brin-and-spgist-index-types-are-not-supported",
 MinimumVersionFixedIn: (map[string]*ybversion.YBVersion) <nil>
}

AssessmentIssue[25] = (cmd.AssessmentIssue) {
 Category: (string) (len=15) "query_construct",
 CategoryDescription: (string) "",
 TypeName: (string) (len=14) "Advisory Locks",
 TypeDescription: (string) "",
 Impact: (string) "",
 ObjectType: (string) "",
 ObjectName: (string) "",
 SqlStatement: (string) (len=32) "SELECT pg_advisory_unlock($1,$2)",
 DocsLink: (string) (len=113) "https://docs.yugabyte.com/preview/yugabyte-voyager/known-issues/postgresql/#advisory-locks-is-not-yet-implemented",
 MinimumVersionFixedIn: (map[string]*ybversion.YBVersion) <nil>
}


AssessmentIssue[51] = (cmd.AssessmentIssue) {
 Category: (string) (len=8) "datatype",
 CategoryDescription: (string) (len=82) "Data types of the source database that are not supported on the target YugabyteDB.",
 TypeName: (string) (len=14) "int8multirange",
 TypeDescription: (string) "",
 Impact: (string) "",
 ObjectType: (string) (len=6) "column",
 ObjectName: (string) (len=43) "public.bigint_multirange_table.value_ranges",
 SqlStatement: (string) "",
 DocsLink: (string) "",
 MinimumVersionFixedIn: (map[string]*ybversion.YBVersion) <nil>
}


AssessmentIssue[54] = (cmd.AssessmentIssue) {
 Category: (string) (len=17) "migration_caveats",
 CategoryDescription: (string) (len=81) "Migration Caveats highlights the current limitations with the migration workflow.",
 TypeName: (string) (len=17) "POLICY_WITH_ROLES",
 TypeDescription: (string) (len=211) "There are some policies that are created for certain users/roles. During the export schema phase, USERs and GRANTs are not exported. Therefore, they will have to be manually created before running import schema.",
 Impact: (string) "",
 ObjectType: (string) (len=6) "POLICY",
 ObjectName: (string) (len=42) "policy_test_report ON public.test_xml_type",
 SqlStatement: (string) (len=85) "CREATE POLICY policy_test_report ON public.test_xml_type TO test_policy USING (true);",
 DocsLink: (string) (len=132) "https://docs.yugabyte.com/preview/yugabyte-voyager/known-issues/postgresql/#policies-on-users-in-source-require-manual-user-creation",
 MinimumVersionFixedIn: (map[string]*ybversion.YBVersion) <nil>
}
AssessmentIssue[60] = (cmd.AssessmentIssue) {
 Category: (string) (len=17) "migration_caveats",
 CategoryDescription: (string) "",
 TypeName: (string) (len=68) "Unsupported Data Types for Live Migration with Fall-forward/Fallback",
 TypeDescription: (string) (len=203) "There are some data types in the schema that are not supported by live migration with fall-forward/fall-back. These columns will be excluded when exporting and importing data in live migration workflows.",
 Impact: (string) "",
 ObjectType: (string) (len=6) "column",
 ObjectName: (string) (len=31) "public.documents.title_tsvector",
 SqlStatement: (string) "",
 DocsLink: (string) (len=130) "https://docs.yugabyte.com/preview/yugabyte-voyager/known-issues/postgresql/#unsupported-datatypes-by-voyager-during-live-migration",
 MinimumVersionFixedIn: (map[string]*ybversion.YBVersion) <nil>
}

TODO: Ensure all the issues (categories, types) are getting generation under AssessmentIssue

Describe if there are any user-facing changes

How was this pull request tested?

existing tests

Does your PR have changes that can cause upgrade issues?

Component Breaking changes?
MetaDB Yes/No
Name registry json Yes/No
Data File Descriptor Json Yes/No
Export Snapshot Status Json Yes/No
Import Data State Yes/No
Export Status Json Yes/No
Data .sql files of tables Yes/No
Export and import data queue Yes/No
Schema Dump Yes/No
AssessmentDB Yes/No
Sizing DB Yes/No
Migration Assessment Report Json Yes/No
Callhome Json Yes/No
YugabyteD Tables Yes/No
TargetDB Metadata Tables Yes/No

@sanyamsinghal sanyamsinghal self-assigned this Jan 6, 2025
return assessmentIssues
}

// TODO: will replace fetchUnsupportedPGFeaturesFromSchemaReport()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These functions will replace the existing codepath after UI updates are implemented.

@sanyamsinghal if we will be replacing the old functions after UI changes then how will it still work to get the previous structure as I believe we still need that for YugabyteD and maybe callhome. cc: @makalaaneesh

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm good catch, we might have to retain this then till the time ybd versions have moved to flattened AssessmentIssue approach.

To hide the current unflatten things in AssessmentReport struct, we can mark their json tag as "-" to avoid it getting in the assessmentReport.json

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can't remove them from the json either, unfortunately 🥲
because we send the json to yugabyted.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah rights, thats bad, we send the complete assessment report json, not the require fields.

@sanyamsinghal sanyamsinghal marked this pull request as ready for review January 6, 2025 12:19
@sanyamsinghal sanyamsinghal force-pushed the sanyam/refactor-assess2 branch from 408ff8f to 134b147 Compare January 7, 2025 10:33
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this file, changes are mostly due to update in the reportCase function signature to have impact also as an argument.

Copy link
Collaborator

@makalaaneesh makalaaneesh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(did not review the impact levels for each issue.)

@@ -973,38 +985,59 @@ func areMinVersionsFixedInEqual(m1 map[string]*ybversion.YBVersion, m2 map[strin
return true
}

func getUnsupportedFeaturesFromSchemaAnalysisReport(featureName string, issueReason string, issueType string, schemaAnalysisReport utils.SchemaReport, displayDDLInHTML bool, description string) UnsupportedFeature {
func getUnsupportedFeaturesFromSchemaAnalysisReport(category string, featureName string, issueReason string, issueType string, schemaAnalysisReport utils.SchemaReport, displayDDLInHTML bool, description string) UnsupportedFeature {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought category was already present in AnalyzeSchemaIssue as IssueType, right? Why, then do we need to explicitly pass this again here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was not sure if category present in analyzeschema issue is reliable.
Here i see that we are assigning it inside the convert function

func convertIssueInstanceToAnalyzeIssue(issueInstance queryissue.QueryIssue, fileName string, isPlPgSQLIssue bool) utils.AnalyzeSchemaIssue {
	issueType := UNSUPPORTED_FEATURES
	switch true {
	case isPlPgSQLIssue:
		issueType = UNSUPPORTED_PLPGSQL_OBJECTS
	case slices.ContainsFunc(MigrationCaveatsIssues, func(i string) bool {
		//Adding the MIGRATION_CAVEATS issueType of the utils.Issue for these issueInstances in MigrationCaveatsIssues
		return strings.Contains(issueInstance.Name, i)
	}):
		issueType = MIGRATION_CAVEATS
	case strings.HasPrefix(issueInstance.Name, UNSUPPORTED_DATATYPE):
		//Adding the UNSUPPORTED_DATATYPES issueType of the utils.Issue for these issues whose TypeName starts with "Unsupported datatype ..."
		issueType = UNSUPPORTED_DATATYPES
	}

Also we are naming it differently right now for assessment issue.
I thought its safer to provide when the caller already know.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@priyanshi-yb can confirm this, but I think we have to actually rely on the category set by the convertIssueInstanceToAnalyzeIssue . Caller of getUnsupportedFeaturesFromSchemaAnalysisReport is just looking for certain issue types, but issueType:category is not 1:1. For example, advisory locks can come up in a DML_QUERY or in PLPGSQL. Same issue type, different category.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes we can rely on convertIssueInstanceToAnalyzeIssue's IssueType which is the actual category of FEATURE, PLPGPSQL, DATATYPE

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

yb-voyager/cmd/assessMigrationCommand.go Show resolved Hide resolved
yb-voyager/cmd/assessMigrationCommand.go Show resolved Hide resolved
yb-voyager/src/issue/issue.go Show resolved Hide resolved
yb-voyager/src/query/queryissue/issues_dml.go Show resolved Hide resolved
@sanyamsinghal sanyamsinghal force-pushed the sanyam/refactor-assess2 branch from 3cee8cf to 3ca100c Compare January 7, 2025 16:53
yb-voyager/cmd/assessMigrationCommand.go Outdated Show resolved Hide resolved
yb-voyager/cmd/assessMigrationCommand.go Show resolved Hide resolved
@@ -19,10 +19,24 @@ const (
// Database Object types
TABLE = "table"
FUNCTION = "function"
COLUMN = "column"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

db object types are mostly used all in caps in code TABLE, FUNCTION or COLUMN

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it has been there like that before, lets change it later. Don't want to risk the scope of this PR.

yb-voyager/src/query/queryissue/issues_dml.go Show resolved Hide resolved
Copy link
Collaborator

@makalaaneesh makalaaneesh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@sanyamsinghal sanyamsinghal merged commit d490424 into main Jan 8, 2025
67 checks passed
@sanyamsinghal sanyamsinghal deleted the sanyam/refactor-assess2 branch January 8, 2025 08:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants