20559: Test concurrent writes using same token.
[arvados.git] / services / ws / event_source.go
index 60d4d40aca67ee3b504a8dba6c71def29caa1ba5..923a341b7520825079cce6dfeaac5debbd56bad4 100644 (file)
@@ -132,16 +132,21 @@ func (ps *pgEventSource) setup() {
                Help:      "Open connections to the database",
        }, []string{"inuse"})
        ps.Reg.MustRegister(openConnections)
+
+       updateDBStats := func() {
+               stats := ps.db.Stats()
+               maxConnections.Set(float64(stats.MaxOpenConnections))
+               openConnections.WithLabelValues("0").Set(float64(stats.Idle))
+               openConnections.WithLabelValues("1").Set(float64(stats.InUse))
+       }
        go func() {
                <-ps.ready
                if ps.db == nil {
                        return
                }
+               updateDBStats()
                for range time.Tick(time.Second) {
-                       stats := ps.db.Stats()
-                       maxConnections.Set(float64(stats.MaxOpenConnections))
-                       openConnections.WithLabelValues("0").Set(float64(stats.Idle))
-                       openConnections.WithLabelValues("1").Set(float64(stats.InUse))
+                       updateDBStats()
                }
        }()
 }
@@ -192,7 +197,7 @@ func (ps *pgEventSource) Run() {
                return
        }
        if ps.MaxOpenConns <= 0 {
-               ps.Logger.Warn("no database connection limit configured -- consider setting PostgresPool>0 in arvados-ws configuration file")
+               ps.Logger.Warn("no database connection limit configured -- consider setting PostgreSQL.ConnectionPool>0 in arvados-ws configuration file")
        }
        db.SetMaxOpenConns(ps.MaxOpenConns)
        if err = db.Ping(); err != nil {
@@ -276,7 +281,7 @@ func (ps *pgEventSource) Run() {
                                ps.Logger.WithField("pqEvent", pqEvent).Error("unexpected notify from wrong channel")
                                continue
                        }
-                       logID, err := strconv.ParseUint(pqEvent.Extra, 10, 64)
+                       logID, err := strconv.ParseInt(pqEvent.Extra, 10, 64)
                        if err != nil {
                                ps.Logger.WithField("pqEvent", pqEvent).Error("bad notify payload")
                                continue