]> arthur.barton.de Git - netdata.git/blobdiff - src/rrd.c
Merge pull request #1744 from l2isbad/web_log_plugin
[netdata.git] / src / rrd.c
index 16375c579b94f914acf78bd2df0cb7f2a19f574b..17774ba2d9a39be1883fba4490ab114acd2c7fee 100644 (file)
--- a/src/rrd.c
+++ b/src/rrd.c
@@ -485,7 +485,7 @@ RRDSET *rrdset_create(const char *type, const char *id, const char *name, const
 
     RRDSET *st = rrdset_find(fullid);
     if(st) {
-        error("Cannot create rrd stats for '%s', it already exists.", fullid);
+        debug(D_RRD_CALLS, "RRDSET '%s', already exists.", fullid);
         return st;
     }
 
@@ -650,7 +650,7 @@ RRDDIM *rrddim_add(RRDSET *st, const char *id, const char *name, long multiplier
 {
     RRDDIM *rd = rrddim_find(st, id);
     if(rd) {
-        error("Cannot create rrd dimension '%s/%s', it already exists.", st->id, name);
+        debug(D_RRD_CALLS, "Cannot create rrd dimension '%s/%s', it already exists.", st->id, name?name:"<NONAME>");
         return rd;
     }
 
@@ -902,7 +902,10 @@ void rrdset_save_all(void) {
     RRDSET *st;
     RRDDIM *rd;
 
-    rrdhost_rdlock(&localhost);
+    // we get an write lock
+    // to ensure only one thread is saving the database
+    rrdhost_rwlock(&localhost);
+
     for(st = localhost.rrdset_root; st ; st = st->next) {
         pthread_rwlock_rdlock(&st->rwlock);
 
@@ -920,6 +923,7 @@ void rrdset_save_all(void) {
 
         pthread_rwlock_unlock(&st->rwlock);
     }
+
     rrdhost_unlock(&localhost);
 }
 
@@ -1038,8 +1042,10 @@ void rrdset_next_usec(RRDSET *st, usec_t microseconds)
     }
     else {
         // microseconds has the time since the last collection
+#ifdef NETDATA_INTERNAL_CHECKS
         usec_t now_usec = timeval_usec(&now);
         usec_t last_usec = timeval_usec(&st->last_collected_time);
+#endif
         usec_t since_last_usec = dt_usec(&now, &st->last_collected_time);
 
         // verify the microseconds given is good