Browse Source

feat(tsdb/agent): notify remote storage when commit happens (#13223)

Signed-off-by: Julien Levesy <jlevesy@gmail.com>
Signed-off-by: Callum Styan <callumstyan@gmail.com>
Co-authored-by: Callum Styan <callumstyan@gmail.com>
pull/13224/head^2
Julien Levesy 12 months ago committed by GitHub
parent
commit
501f514389
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      CHANGELOG.md
  2. 1
      cmd/prometheus/main.go
  3. 12
      tsdb/agent/db.go

4
CHANGELOG.md

@ -1,5 +1,9 @@
# Changelog # Changelog
## unreleased
* [BUGFIX] Agent: Participate in notify calls. #13223
## 2.48.0 / 2023-11-16 ## 2.48.0 / 2023-11-16
* [CHANGE] Remote-write: respect Retry-After header on 5xx errors. #12677 * [CHANGE] Remote-write: respect Retry-After header on 5xx errors. #12677

1
cmd/prometheus/main.go

@ -1127,6 +1127,7 @@ func main() {
) )
localStorage.Set(db, 0) localStorage.Set(db, 0)
db.SetWriteNotified(remoteStorage)
close(dbOpen) close(dbOpen)
<-cancel <-cancel
return nil return nil

12
tsdb/agent/db.go

@ -241,6 +241,8 @@ type DB struct {
donec chan struct{} donec chan struct{}
stopc chan struct{} stopc chan struct{}
writeNotified wlog.WriteNotified
metrics *dbMetrics metrics *dbMetrics
} }
@ -311,6 +313,12 @@ func Open(l log.Logger, reg prometheus.Registerer, rs *remote.Storage, dir strin
return db, nil return db, nil
} }
// SetWriteNotified allows to set an instance to notify when a write happens.
// It must be used during initialization. It is not safe to use it during execution.
func (db *DB) SetWriteNotified(wn wlog.WriteNotified) {
db.writeNotified = wn
}
func validateOptions(opts *Options) *Options { func validateOptions(opts *Options) *Options {
if opts == nil { if opts == nil {
opts = DefaultOptions() opts = DefaultOptions()
@ -962,6 +970,10 @@ func (a *appender) Commit() error {
a.clearData() a.clearData()
a.appenderPool.Put(a) a.appenderPool.Put(a)
if a.writeNotified != nil {
a.writeNotified.Notify()
}
return nil return nil
} }

Loading…
Cancel
Save