bytebase/bytebase · error

failed to get Trino version

Error message

failed to get Trino version

What it means

SyncInstance starts instance metadata discovery by querying the Trino server version via d.getVersion(ctx). This error wraps any failure of that version query, aborting the sync before catalogs are read. It means the Trino coordinator could not be interrogated for its version.

Source

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

package trino

import (
	"context"

	"github.com/pkg/errors"

	storepb "github.com/bytebase/bytebase/backend/generated-go/store"
	"github.com/bytebase/bytebase/backend/plugin/db"
	"github.com/bytebase/bytebase/backend/plugin/db/util"
)

// SyncInstance syncs the instance.
func (d *Driver) SyncInstance(ctx context.Context) (*db.InstanceMetadata, error) {
	version, err := d.getVersion(ctx)
	if err != nil {
		return nil, errors.Wrap(err, "failed to get Trino version")
	}

	catalogList, err := d.getCatalog(ctx)
	if err != nil {
		return nil, errors.Wrap(err, "failed to get catalog list")
	}

	var catalogMetadata []*storepb.DatabaseSchemaMetadata
	for _, catalog := range catalogList {
		catalogMetadata = append(catalogMetadata, &storepb.DatabaseSchemaMetadata{
			Name: catalog,
		})
	}

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

View on GitHub (pinned to 1870550677)

Solutions

  1. Check the wrapped error: if connection refused, verify the Trino coordinator host and port in the instance DSN
  2. Test connectivity with curl to the coordinator's /v1/info endpoint
  3. Verify authentication credentials (user/password, TLS certs, Kerberos keytab) are valid
  4. Confirm the Trino server is running and healthy before re-running sync

Example fix

// before
instance, err := driver.SyncInstance(ctx) // fails: coordinator on :8081 not :8080
// after
// fix dsn: http://trino-coordinator:8081
instance, err := driver.SyncInstance(ctx)
Defensive patterns

Strategy: retry

Validate before calling

conn, err := d.db.Conn(ctx)
if err != nil {
	return fmt.Errorf("trino unreachable before version sync: %w", err)
}
conn.Close()

Try / catch

version, err := d.getVersion(ctx)
if err != nil {
	if isTransient(err) {
		return retryWithBackoff(3, func() (*db.InstanceMetadata, error) { return d.SyncInstance(ctx) })
	}
	return nil, errors.Wrap(err, "failed to get Trino version")
}

Prevention

When it happens

Trigger: Calling (*trino.Driver).SyncInstance when the underlying SELECT for the version (typically a query against system.runtime.nodes or a driver-capability query) fails — connection refused, bad credentials, or an unexpected result set.

Common situations: Trino coordinator down or unreachable, wrong host/port in the instance DSN, Kerberos/TLS misconfiguration, or a proxy stripping the response.

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/f07bf27f4f011cbf. Report an issue: GitHub.