Files
Samuel Merritt
bd3ca778d1
Fix ValueError from handoff logging.
If you have StatsD logging turned on, then the iterator returned by Ring.get_part_nodes() will emit StatsD packets when it yields a handoff node. That network IO may make eventlet trampoline to another greenthread before returning from next(). Now, if that other greenthread tries to call next() on that same iterator, it blows up with a ValueError. Any socket IO inside a generator's next() method can cause this. It's easiest to reproduce with StatsD logging turned on, but logging to syslog can trigger it too. You can see this happen sometimes in the proxy's make_requests method if two of the primary nodes are down. Greenthread A goes into next() to get a handoff node, then sends a StatsD packet, and so eventlet trampolines to Greenthread B. Now, Greenthread B also calls next() to get a handoff node, and dies with a ValueError. This commit wraps up concurrently-accessed iter_nodes() iterators in a new thing called a GreenthreadSafeIterator that serializes access. Bug 1180110 Change-Id: I8fe13d7295c056a2cab9e084f5966078a49bdc13