summaryrefslogtreecommitdiffstats
path: root/database/sqlite/sqlite_aclk.c
diff options
context:
space:
mode:
Diffstat (limited to 'database/sqlite/sqlite_aclk.c')
-rw-r--r--database/sqlite/sqlite_aclk.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/database/sqlite/sqlite_aclk.c b/database/sqlite/sqlite_aclk.c
index 63196a81e..989328097 100644
--- a/database/sqlite/sqlite_aclk.c
+++ b/database/sqlite/sqlite_aclk.c
@@ -209,7 +209,7 @@ struct aclk_database_worker_config *find_inactive_wc_by_node_id(char *node_id)
void aclk_sync_exit_all()
{
- rrd_wrlock();
+ rrd_rdlock();
RRDHOST *host = localhost;
while(host) {
struct aclk_database_worker_config *wc = host->dbsync_worker;
@@ -508,11 +508,16 @@ void aclk_database_worker(void *arg)
aclk_update_retention(wc, cmd);
aclk_process_dimension_deletion(wc, cmd);
break;
-#endif
// NODE_INSTANCE DETECTION
+ case ACLK_DATABASE_ORPHAN_HOST:
+ wc->host = NULL;
+ wc->is_orphan = 1;
+ aclk_add_worker_thread(wc);
+ break;
+#endif
case ACLK_DATABASE_TIMER:
- if (unlikely(localhost && !wc->host)) {
+ if (unlikely(localhost && !wc->host && !wc->is_orphan)) {
if (claimed()) {
wc->host = rrdhost_find_by_guid(wc->host_guid, 0);
if (wc->host) {
@@ -567,7 +572,7 @@ void aclk_database_worker(void *arg)
freez(loop);
- rrd_wrlock();
+ rrd_rdlock();
if (likely(wc->host))
wc->host->dbsync_worker = NULL;
freez(wc);
@@ -815,7 +820,7 @@ void aclk_data_rotated(void)
return;
time_t next_rotation_time = now_realtime_sec()+ACLK_DATABASE_ROTATION_DELAY;
- rrd_wrlock();
+ rrd_rdlock();
RRDHOST *this_host = localhost;
while (this_host) {
struct aclk_database_worker_config *wc = this_host->dbsync_worker;