{"record":{"id":"f7d606d98069eea6","repo":"bytebase/bytebase","slug":"failed-to-get-views-from-database-q-f7d606","errorCode":null,"errorMessage":"failed to get views from database %q","messagePattern":"failed to get views from database %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/plugin/db/spanner/sync.go","lineNumber":82,"sourceCode":"\t}\n\n\ttx := d.client.ReadOnlyTransaction()\n\tdefer tx.Close()\n\n\tdatabaseMetadata := &storepb.DatabaseSchemaMetadata{\n\t\tName: d.databaseName,\n\t}\n\tcolumnMap, err := getColumn(ctx, tx)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"failed to get table columns from database %q\", d.databaseName)\n\t}\n\ttableMap, err := getTable(ctx, tx, columnMap)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"failed to get tables from database %q\", d.databaseName)\n\t}\n\tviewMap, err := getView(ctx, tx, columnMap)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"failed to get views from database %q\", d.databaseName)\n\t}\n\n\tschemaNameMap := make(map[string]bool)\n\tfor schemaName := range tableMap {\n\t\tschemaNameMap[schemaName] = true\n\t}\n\tfor schemaName := range viewMap {\n\t\tschemaNameMap[schemaName] = true\n\t}\n\tvar schemaNames []string\n\tfor schemaName := range schemaNameMap {\n\t\tschemaNames = append(schemaNames, schemaName)\n\t}\n\tslices.Sort(schemaNames)\n\tfor _, schemaName := range schemaNames {\n\t\tdatabaseMetadata.Schemas = append(databaseMetadata.Schemas, &storepb.SchemaMetadata{\n\t\t\tName:   schemaName,\n\t\t\tTables: tableMap[schemaName],","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/bytebase/bytebase/blob/1870550677fe08f0d2a78c07acd27541464eb945/backend/plugin/db/spanner/sync.go#L64-L100","documentation":"Raised during Spanner schema sync inside a read-only transaction: the getView helper, which queries INFORMATION_SCHEMA views to enumerate view definitions (using the already-fetched column map), returned an error. This aborts assembly of the DatabaseSchemaMetadata for the database; the cause is in the wrapped error, usually a failed Spanner query or permission issue reading INFORMATION_SCHEMA.","triggerScenarios":"Calling SyncDBSchema when the view listing query in getView returns an error from Spanner.","commonSituations":"Spanner transient failure or quota exhaustion, context cancelled, permissions missing on INFORMATION_SCHEMA.VIEWS, database deleted concurrently.","solutions":["Inspect the wrapped cause for the gRPC status code","Retry the sync after transient failures","Verify read access to INFORMATION_SCHEMA.VIEWS","Extend the sync context timeout"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"ctx, cancel := context.WithTimeout(ctx, 5*time.Minute)\ndefer cancel()","typeGuard":null,"tryCatchPattern":"meta, err := driver.SyncDBSchema(ctx)\nif err != nil && strings.Contains(err.Error(), \"failed to get views\") {\n\t// retry or surface partial metadata\n}","preventionTips":["Give INFORMATION_SCHEMA reads adequate timeouts","Verify view-visibility permissions for the sync account","Retry transient Spanner errors with backoff"],"tags":["spanner","metadata-sync","views","error-wrapping"],"backgroundTag":"sql-query-failed","analyzedSha":"1870550677fe08f0d2a78c07acd27541464eb945","analyzedAt":"2026-09-06T21:16:13.665Z","contentChangedAt":"2026-09-06T21:16:13.665Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}