X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/0561bd0c3c07257fd58ded6c7cfa5feeae97af57..d0414ca727006b821b10b25d3920dc0f66400356:/services/ws/event_source.go diff --git a/services/ws/event_source.go b/services/ws/event_source.go index a4e886872c..9acfca50e4 100644 --- a/services/ws/event_source.go +++ b/services/ws/event_source.go @@ -243,11 +243,13 @@ func (ps *pgEventSource) NewSink() eventSink { } func (ps *pgEventSource) DB() *sql.DB { + ps.WaitReady() return ps.db } func (ps *pgEventSource) DBHealth() error { - ctx, _ := context.WithDeadline(context.Background(), time.Now().Add(time.Second)) + ctx, cancel := context.WithDeadline(context.Background(), time.Now().Add(time.Second)) + defer cancel() var i int return ps.db.QueryRowContext(ctx, "SELECT 1").Scan(&i) } @@ -286,7 +288,7 @@ func (sink *pgEventSink) Stop() { // Ensure this sink cannot fill up and block the // server-side queue (which otherwise could in turn // block our mtx.Lock() here) - for _ = range sink.channel { + for range sink.channel { } }() sink.source.mtx.Lock()