bytebase/bytebase · error

failed to get schema list for catalog %s

Error message

failed to get schema list for catalog %s

What it means

SyncDBSchema fetches the list of schemas in the target catalog via d.getSchemaList(ctx). On failure it wraps the error with the catalog name (d.databaseName). The schema enumeration query against Trino's system JDBC tables failed, so database-level sync aborts.

Source

Thrown at backend/plugin/db/trino/sync.go:48

	}

	return &db.InstanceMetadata{
		Version:   version,
		Databases: catalogMetadata,
		Metadata:  &storepb.Instance{},
	}, nil
}

// SyncDBSchema syncs a single database schema.
func (d *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchemaMetadata, error) {
	catalog := d.databaseName
	dbMeta := &storepb.DatabaseSchemaMetadata{
		Name: catalog,
	}

	schemaNames, err := d.getSchemaList(ctx)
	if err != nil {
		return nil, errors.Wrapf(err, "failed to get schema list for catalog %s", d.databaseName)
	}

	// Fetch all tables in all schemas in one query
	allTables, err := d.fetchAllTablesForCatalog(ctx, schemaNames)
	if err != nil {
		return nil, errors.Wrapf(err, "failed to fetch tables for catalog %s", d.databaseName)
	}

	// Fetch all columns for all tables in one query
	allColumns, err := d.fetchAllColumnsForCatalog(ctx)
	if err != nil {
		return nil, errors.Wrapf(err, "failed to fetch columns for catalog %s", d.databaseName)
	}

	// Organize the data into schemas
	var schemas []*storepb.SchemaMetadata
	for _, schemaName := range schemaNames {
		tables := allTables[schemaName]

View on GitHub (pinned to 1870550677)

Solutions

  1. Verify the catalog name in the connection config matches a catalog listed by SHOW CATALOGS
  2. Run SELECT * FROM system.jdbc.schemata AS the sync user to check access
  3. Fix connectivity/auth issues indicated by the wrapped error
  4. Re-run database sync after correcting the catalog configuration

Example fix

// before
dbMeta, err := driver.SyncDBSchema(ctx, db) // catalog "prod1" doesn't exist
// after
// correct databaseName in instance config to "prod"
dbMeta, err := driver.SyncDBSchema(ctx, db)
Defensive patterns

Strategy: validation

Validate before calling

catalogs, err := d.getCatalog(ctx)
if err != nil {
	return fmt.Errorf("cannot enumerate catalogs: %w", err)
}
if !slices.Contains(catalogs, d.databaseName) {
	return fmt.Errorf("catalog %q not found on coordinator", d.databaseName)
}

Try / catch

schemaNames, err := d.getSchemaList(ctx)
if err != nil {
	return nil, errors.Wrapf(err, "failed to get schema list for catalog %s", d.databaseName)
}

Prevention

When it happens

Trigger: Calling SyncDBSchema when the schema-list query (SELECT over system.jdbc.schemata) fails because of connectivity, missing catalog, or permission errors.

Common situations: Catalog name typo in the instance configuration, catalog was removed from the coordinator, or the sync user cannot read system.jdbc tables.

Understand the failure class

Background: "query failed", "%w: SQL error" — wrapped database query errors in Go libraries explained — this error's family across 3 libraries.

Related errors


AI-assisted analysis of bytebase/bytebase@1870550677 (2026-09-06). Data as JSON: /api/errors/4a52d96bec2b4f7d. Report an issue: GitHub.