mirror of
https://github.com/prometheus/prometheus
synced 2024-12-26 08:33:06 +00:00
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:
parent
52b15d2195
commit
501f514389
@ -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
|
||||
|
@ -1127,6 +1127,7 @@ func main() {
|
||||
)
|
||||
|
||||
localStorage.Set(db, 0)
|
||||
db.SetWriteNotified(remoteStorage)
|
||||
close(dbOpen)
|
||||
<-cancel
|
||||
return nil
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user