From a5a27dd8cf53701f62a2ad866fba37cd7fae5741 Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Wed, 7 Dec 2016 08:54:17 -0800 Subject: [PATCH] Fixup concurrent modification Copy the joined group set before iterating over it and discard members (just incase the driver isn't discarding) after leaving future completion (success or failure). Closes-Bug: #1647942 Change-Id: I43cdb6aeaff53feb6f4a8f53ab4664272bff856f --- tooz/coordination.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) mode change 100644 => 100755 tooz/coordination.py diff --git a/tooz/coordination.py b/tooz/coordination.py old mode 100644 new mode 100755 index 5ec81ba2..1b20eec4 --- a/tooz/coordination.py +++ b/tooz/coordination.py @@ -408,11 +408,13 @@ class CoordinationDriver(object): if self.heart.is_alive(): self.heart.stop() self.heart.wait() - leaving = [self.leave_group(group) - for group in self._joined_groups] - for leave in leaving: + # Some of the drivers modify joined_groups when being called to leave + # so clone it so that we aren't modifying something while iterating. + joined_groups = self._joined_groups.copy() + leaving = [self.leave_group(group) for group in joined_groups] + for fut in leaving: try: - leave.get() + fut.get() except ToozError: # Whatever happens, ignore. Maybe we got booted out/never # existed in the first place, or something is down, but we just