Blob Blame History Raw
From da17fd0265ffe3b4456c4f81141439c851504281 Mon Sep 17 00:00:00 2001
From: Andrew Beekhof <andrew@beekhof.net>
Date: Thu, 7 Jan 2016 11:33:34 +1100
Subject: [PATCH] Fix: attrd: Correctly implement mass removal of a node's
 attributes

---
 attrd/commands.c | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/attrd/commands.c b/attrd/commands.c
index 378a4f8..28e4a81 100644
--- a/attrd/commands.c
+++ b/attrd/commands.c
@@ -541,8 +541,9 @@ attrd_peer_message(crm_node_t *peer, xmlNode *xml)
         } else {
             host = NULL;
         }
-        attrd_peer_remove(host_id, host, TRUE, peer->uname);
 
+        crm_notice("Processing %s from %s: %s %u", op, peer->uname, host, host_id);
+        attrd_peer_remove(host_id, host, TRUE, peer->uname);
 
     } else if (safe_str_eq(op, ATTRD_OP_SYNC_RESPONSE)
               && safe_str_neq(peer->uname, attrd_cluster->uname)) {
@@ -589,15 +590,27 @@ attrd_peer_remove(uint32_t nodeid, const char *host, gboolean uncache, const cha
     attribute_t *a = NULL;
     GHashTableIter aIter;
 
-    crm_notice("Removing all %s attributes for %s", host, source);
+    crm_notice("Removing all %s (%u) attributes for %s", host, nodeid, source);
     if(host == NULL) {
         return;
     }
 
     g_hash_table_iter_init(&aIter, attributes);
     while (g_hash_table_iter_next(&aIter, NULL, (gpointer *) & a)) {
-        if(g_hash_table_remove(a->values, host)) {
-            crm_debug("Removed %s[%s] for %s", a->id, host, source);
+        attribute_value_t *v = g_hash_table_lookup(a->values, host);
+
+        if(v && v->current) {
+            free(v->current);
+            v->current = NULL;
+            a->changed = TRUE;
+
+            crm_debug("Removed %s[%s]=%s for %s", a->id, host, v->current, source);
+            if(a->timer) {
+                crm_trace("Delayed write out (%dms) for %s", a->timeout_ms, a->id);
+                mainloop_timer_start(a->timer);
+            } else {
+                write_or_elect_attribute(a);
+            }
         }
     }
 
-- 
1.8.3.1