{"record":{"id":"fa17b55a2591fe2e","repo":"bytebase/bytebase","slug":"failed-to-get-function-dependency-tables-from-data","errorCode":null,"errorMessage":"failed to get function dependency tables from database %q","messagePattern":"failed to get function dependency tables from database %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/plugin/db/pg/sync.go","lineNumber":165,"sourceCode":"\t\tif err != nil {\n\t\t\treturn nil, errors.Wrapf(err, \"failed to get table partitions from database %q\", d.databaseName)\n\t\t}\n\t}\n\tviewMap, viewOidMap, err := getViews(txn, columnMap, triggerMap, extensionDepend)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"failed to get views from database %q\", d.databaseName)\n\t}\n\truleMap, err := getRules(txn)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"failed to get rules from database %q\", d.databaseName)\n\t}\n\tmaterializedViewMap, materializedViewOidMap, err := getMaterializedViews(txn, indexMap, triggerMap, extensionDepend)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"failed to get materialized views from database %q\", d.databaseName)\n\t}\n\tfunctionDependencyTables, err := getFunctionDependencyTables(txn)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"failed to get function dependency tables from database %q\", d.databaseName)\n\t}\n\tfunctionMap, err := getFunctions(txn, functionDependencyTables, tableOidMap, viewOidMap, materializedViewOidMap, extensionDepend)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"failed to get functions from database %q\", d.databaseName)\n\t}\n\tsequenceMap, err := getSequences(txn, tableOidMap, extensionDepend)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"failed to get sequences from database %q\", d.databaseName)\n\t}\n\n\textensions, err := getExtensions(txn)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"failed to get extensions from database %q\", d.databaseName)\n\t}\n\n\tenumTypes, err := getEnumTypes(txn, extensionDepend)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"failed to get enum types from database %q\", d.databaseName)","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/bytebase/bytebase/blob/1870550677fe08f0d2a78c07acd27541464eb945/backend/plugin/db/pg/sync.go#L147-L183","documentation":"As part of SyncDBSchema, getFunctionDependencyTables(txn) queries dependency catalogs (pg_depend/pg_rewrite) to find tables referenced by function bodies. This wrapper fires when that catalog query fails, aborting the whole schema sync since SyncDBSchema returns nil on any sub-step failure.","triggerScenarios":"Calling SyncDBSchema when the function-dependency catalog query errors: connection loss mid-transaction, permission restriction on pg_depend, or a query timeout on databases with many functions/dependencies.","commonSituations":"Long-running syncs on databases with thousands of functions; restricted roles in hardened environments; unstable connections to cloud Postgres through pgbouncer in transaction mode.","solutions":["Read the wrapped cause to identify the real driver error.","Ensure the sync role retains default public read access to pg_depend and related catalogs.","Increase timeouts and retry; split very large schemas if catalog scans are slow.","Avoid transaction-mode poolers that can sever the sync's single catalog transaction."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"SELECT count(*) FROM pg_depend; -- dependency catalog accessible?","typeGuard":null,"tryCatchPattern":"deps, err := getFunctionDependencyTables(txn)\nif err != nil {\n\tif isTransient(err) { return retrySync(txn) }\n\treturn fmt.Errorf(\"sync aborted: %w\", err)\n}","preventionTips":["Do not revoke catalog privileges from the sync role","Split very large function-heavy schemas into scoped syncs","Check server logs for backend terminations during sync","Avoid transaction-pooling middleware for sync connections"],"tags":["postgres","schema-sync","functions","catalog"],"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-14T00:17:10.932Z"}