12087: Don't report read/write errors on terminated sessions.
[arvados.git] / services / ws / event_source.go
index a4e886872c49829a27a1223d6cdfd691a2e5efff..cfb828b2a5d84c6d16407866374e1f4900185f84 100644 (file)
@@ -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)
 }