{"record":{"id":"dd6373ea28d44d87","repo":"bytebase/bytebase","slug":"failed-to-get-tables-from-datashare-database-q","errorCode":null,"errorMessage":"failed to get tables from datashare database %q","messagePattern":"failed to get tables from datashare database %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/plugin/db/redshift/sync.go","lineNumber":88,"sourceCode":"\t\treturn nil, common.Errorf(common.NotFound, \"database %q not found\", d.databaseName)\n\t}\n\n\ttxn, err := d.db.BeginTx(ctx, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer txn.Rollback()\n\n\tschemaList, err := d.getSchemas(txn)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"failed to get schemas from database %q\", d.databaseName)\n\t}\n\tvar tableMap map[string][]*storepb.TableMetadata\n\tvar viewMap map[string][]*storepb.ViewMetadata\n\tif d.datashare {\n\t\ttableMap, err = d.getDatashareTables(txn)\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrapf(err, \"failed to get tables from datashare database %q\", d.databaseName)\n\t\t}\n\t} else {\n\t\tcolumnMap, err := getTableColumns(txn)\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrap(err, \"failed to get table columns\")\n\t\t}\n\t\ttableMap, err = getTables(txn, columnMap)\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrapf(err, \"failed to get tables from database %q\", d.databaseName)\n\t\t}\n\t\tviewMap, err = getViews(txn, columnMap)\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrapf(err, \"failed to get views from database %q\", d.databaseName)\n\t\t}\n\t}\n\tif err := txn.Commit(); err != nil {\n\t\treturn nil, err\n\t}","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/bytebase/bytebase/blob/1870550677fe08f0d2a78c07acd27541464eb945/backend/plugin/db/redshift/sync.go#L70-L106","documentation":"When the driver is created with datashare enabled, SyncDBSchema calls d.getDatashareTables(txn) to read tables shared from a datashare producer database. Failure there is wrapped as \"failed to get tables from datashare database %q\". It indicates the datashare table enumeration query failed for the consumer database.","triggerScenarios":"SyncDBSchema with d.datashare == true and getDatashareTables(txn) failing — the consumer cannot read the datashare, the share was revoked/altered, or the catalog query over the shared tables errors.","commonSituations":"Producer altered or dropped the datashare after the consumer configured sync; the consumer database lacks CREATE DATASHARE/USAGE grants; cross-region datashares whose metadata views are temporarily unavailable.","solutions":["Verify the consumer still has USAGE on the datashare: SHOW DATASHARES / GRANT USAGE ON DATASHARE <share> TO DATABASE <db>.","Re-run ALTER DATABASE <db> WITH... / re-associate the datashare if the producer changed it.","Check with the producer account that the share and its objects still exist.","If datashare sync is not needed, recreate the driver with datashare disabled to take the normal getTables path."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// ensure the consumer still has usage on the datashare\n// SHOW DATASHARES;  -- confirm share exists and is associated\n// GRANT USAGE ON DATASHARE <share> TO DATABASE <db>;  -- re-grant if revoked","typeGuard":null,"tryCatchPattern":"meta, err := d.SyncDBSchema(ctx)\nif err != nil && strings.Contains(err.Error(), \"datashare\") {\n\treturn fmt.Errorf(\"datashare metadata unavailable (check USAGE grants and share state): %w\", err)\n}","preventionTips":["Set up alerts when a producer alters/revokes a datashare","Re-grant USAGE on datashares after any producer-side changes","Fall back to non-datashare sync when the share is unavailable"],"tags":["redshift","datashare","schema-sync","permissions"],"backgroundTag":"database-query-failed","analyzedSha":"1870550677fe08f0d2a78c07acd27541464eb945","analyzedAt":"2026-09-06T21:16:13.665Z","contentChangedAt":"2026-09-06T21:16:13.665Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}