diff --git a/cmd/bd/import.go b/cmd/bd/import.go index 0c0c298e32..1f57cdd4dd 100644 --- a/cmd/bd/import.go +++ b/cmd/bd/import.go @@ -26,7 +26,7 @@ EXAMPLES: bd import backup.jsonl # Import from a specific file bd import --dry-run # Show what would be imported`, GroupID: "sync", - RunE: runImport, + RunE: runImport, } var ( diff --git a/internal/storage/dolt/store.go b/internal/storage/dolt/store.go index 02417fe8b4..c90b3c179a 100644 --- a/internal/storage/dolt/store.go +++ b/internal/storage/dolt/store.go @@ -558,6 +558,15 @@ func applyConfigDefaults(cfg *Config) { cfg.ServerPort = p } } + // If env var didn't provide a port, consult the full resolution chain: + // port file > config.yaml > metadata.json (GH#2590). + // Previously, port 0 fell through to the MySQL driver default (3307), + // causing cross-project connections when another Dolt sat on 3307. + if cfg.ServerPort == 0 && cfg.Path != "" { + if resolved := doltserver.DefaultConfig(cfg.Path); resolved.Port > 0 { + cfg.ServerPort = resolved.Port + } + } // Port 0 means "not yet resolved" — auto-start (EnsureRunning) will // allocate an ephemeral port. Don't default to 3307 as that caused // cross-project data leakage (GH#2098, GH#2372). @@ -1844,7 +1853,6 @@ func (s *DoltStore) tryAutoResolveMetadataConflicts(ctx context.Context, tx *sql return true, nil } - // Branch creates a new branch func (s *DoltStore) Branch(ctx context.Context, name string) (retErr error) { ctx, span := doltTracer.Start(ctx, "dolt.branch",