ensure only one thread is saving the db at a time
Costa Tsaousis (ktsaou) committed
Jan 14, 2017 at 14:29 UTC
af41d66aa7254422c77224c445a8691a6c0f0503
1 file changed
+5
-1
src/rrd.c
+5
-1
@@ -902,7 +902,10 @@ void rrdset_save_all(void) {
902
RRDSET *st;
903
RRDDIM *rd;
904
905
- rrdhost_rdlock(&localhost);
905
+ // we get an write lock
906
+ // to ensure only one thread is saving the database
907
+ rrdhost_rwlock(&localhost);
908
+
909
for(st = localhost.rrdset_root; st ; st = st->next) {
910
pthread_rwlock_rdlock(&st->rwlock);
911
@@ -920,6 +923,7 @@ void rrdset_save_all(void) {
923
924
pthread_rwlock_unlock(&st->rwlock);
925
}
926
+
927
rrdhost_unlock(&localhost);
928
}
929