X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/7800f12fccea5675d71159ddf7c868f4074f8f56..df591042778408d03d410d5c22a669d85652d1ea:/services/ws/event_source.go diff --git a/services/ws/event_source.go b/services/ws/event_source.go index 6a308b3a62..9acfca50e4 100644 --- a/services/ws/event_source.go +++ b/services/ws/event_source.go @@ -1,3 +1,7 @@ +// Copyright (C) The Arvados Authors. All rights reserved. +// +// SPDX-License-Identifier: AGPL-3.0 + package main import ( @@ -239,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) } @@ -263,6 +269,7 @@ func (ps *pgEventSource) DebugStatus() interface{} { "QueueDelay": stats.Duration(ps.lastQDelay), "Sinks": len(ps.sinks), "SinksBlocked": blocked, + "DBStats": ps.db.Stats(), } } @@ -281,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()