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>
This commit is contained in:
Julien Levesy 2023-12-01 23:00:26 +01:00 committed by GitHub
parent 52b15d2195
commit 501f514389
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 0 deletions

View file

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

View file

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

View file

@ -241,6 +241,8 @@ type DB struct {
donec chan struct{}
stopc chan struct{}
writeNotified wlog.WriteNotified
metrics *dbMetrics
}
@ -311,6 +313,12 @@ func Open(l log.Logger, reg prometheus.Registerer, rs *remote.Storage, dir strin
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 {
if opts == nil {
opts = DefaultOptions()
@ -962,6 +970,10 @@ func (a *appender) Commit() error {
a.clearData()
a.appenderPool.Put(a)
if a.writeNotified != nil {
a.writeNotified.Notify()
}
return nil
}