projects
/
arvados.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
20559: Test concurrent writes using same token.
[arvados.git]
/
services
/
ws
/
event_source.go
diff --git
a/services/ws/event_source.go
b/services/ws/event_source.go
index 60d4d40aca67ee3b504a8dba6c71def29caa1ba5..923a341b7520825079cce6dfeaac5debbd56bad4 100644
(file)
--- a/
services/ws/event_source.go
+++ b/
services/ws/event_source.go
@@
-132,16
+132,21
@@
func (ps *pgEventSource) setup() {
Help: "Open connections to the database",
}, []string{"inuse"})
ps.Reg.MustRegister(openConnections)
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
}
go func() {
<-ps.ready
if ps.db == nil {
return
}
+ updateDBStats()
for range time.Tick(time.Second) {
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 {
return
}
if ps.MaxOpenConns <= 0 {
- ps.Logger.Warn("no database connection limit configured -- consider setting Postgre
s
Pool>0 in arvados-ws configuration file")
+ ps.Logger.Warn("no database connection limit configured -- consider setting Postgre
SQL.Connection
Pool>0 in arvados-ws configuration file")
}
db.SetMaxOpenConns(ps.MaxOpenConns)
if err = db.Ping(); err != nil {
}
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
}
ps.Logger.WithField("pqEvent", pqEvent).Error("unexpected notify from wrong channel")
continue
}
- logID, err := strconv.Parse
Ui
nt(pqEvent.Extra, 10, 64)
+ logID, err := strconv.Parse
I
nt(pqEvent.Extra, 10, 64)
if err != nil {
ps.Logger.WithField("pqEvent", pqEvent).Error("bad notify payload")
continue
if err != nil {
ps.Logger.WithField("pqEvent", pqEvent).Error("bad notify payload")
continue