Blame SOURCES/0110-Fix-attrd-Correctly-implement-mass-removal-of-a-node.patch

0240e4
From da17fd0265ffe3b4456c4f81141439c851504281 Mon Sep 17 00:00:00 2001
0240e4
From: Andrew Beekhof <andrew@beekhof.net>
0240e4
Date: Thu, 7 Jan 2016 11:33:34 +1100
0240e4
Subject: [PATCH] Fix: attrd: Correctly implement mass removal of a node's
0240e4
 attributes
0240e4
0240e4
---
0240e4
 attrd/commands.c | 21 +++++++++++++++++----
0240e4
 1 file changed, 17 insertions(+), 4 deletions(-)
0240e4
0240e4
diff --git a/attrd/commands.c b/attrd/commands.c
0240e4
index 378a4f8..28e4a81 100644
0240e4
--- a/attrd/commands.c
0240e4
+++ b/attrd/commands.c
0240e4
@@ -541,8 +541,9 @@ attrd_peer_message(crm_node_t *peer, xmlNode *xml)
0240e4
         } else {
0240e4
             host = NULL;
0240e4
         }
0240e4
-        attrd_peer_remove(host_id, host, TRUE, peer->uname);
0240e4
 
0240e4
+        crm_notice("Processing %s from %s: %s %u", op, peer->uname, host, host_id);
0240e4
+        attrd_peer_remove(host_id, host, TRUE, peer->uname);
0240e4
 
0240e4
     } else if (safe_str_eq(op, ATTRD_OP_SYNC_RESPONSE)
0240e4
               && safe_str_neq(peer->uname, attrd_cluster->uname)) {
0240e4
@@ -589,15 +590,27 @@ attrd_peer_remove(uint32_t nodeid, const char *host, gboolean uncache, const cha
0240e4
     attribute_t *a = NULL;
0240e4
     GHashTableIter aIter;
0240e4
 
0240e4
-    crm_notice("Removing all %s attributes for %s", host, source);
0240e4
+    crm_notice("Removing all %s (%u) attributes for %s", host, nodeid, source);
0240e4
     if(host == NULL) {
0240e4
         return;
0240e4
     }
0240e4
 
0240e4
     g_hash_table_iter_init(&aIter, attributes);
0240e4
     while (g_hash_table_iter_next(&aIter, NULL, (gpointer *) & a)) {
0240e4
-        if(g_hash_table_remove(a->values, host)) {
0240e4
-            crm_debug("Removed %s[%s] for %s", a->id, host, source);
0240e4
+        attribute_value_t *v = g_hash_table_lookup(a->values, host);
0240e4
+
0240e4
+        if(v && v->current) {
0240e4
+            free(v->current);
0240e4
+            v->current = NULL;
0240e4
+            a->changed = TRUE;
0240e4
+
0240e4
+            crm_debug("Removed %s[%s]=%s for %s", a->id, host, v->current, source);
0240e4
+            if(a->timer) {
0240e4
+                crm_trace("Delayed write out (%dms) for %s", a->timeout_ms, a->id);
0240e4
+                mainloop_timer_start(a->timer);
0240e4
+            } else {
0240e4
+                write_or_elect_attribute(a);
0240e4
+            }
0240e4
         }
0240e4
     }
0240e4
 
0240e4
-- 
0240e4
1.8.3.1
0240e4