From 63ddb3500f3516a28002c24c6b39eb2dce78193f Mon Sep 17 00:00:00 2001 From: Mike Place Date: Thu, 14 Aug 2014 13:45:28 -0600 Subject: [PATCH] Do not use non_blocking mode on master event bus In my testing, using the NOBLOCK option in ZeroMQ resulted in an approx. mesasge loss of between 0.5% and 1.5% across 1M messages delivered at high-speed. Removing that option resulted in a slight performance hit but 100% of messages were delivered. --- salt/utils/event.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/salt/utils/event.py b/salt/utils/event.py index de2734e613..b6ca4658c6 100644 --- a/salt/utils/event.py +++ b/salt/utils/event.py @@ -290,7 +290,8 @@ class SaltEvent(object): continue try: - ret = self.get_event_noblock() + ret = self.get_event_block() # Please do not use non-blocking mode here. + # Reliability is more important than pure speed on the event bus. except zmq.ZMQError as ex: if ex.errno == errno.EAGAIN or ex.errno == errno.EINTR: continue @@ -353,6 +354,14 @@ class SaltEvent(object): mtag, data = self.unpack(raw, self.serial) return {'data': data, 'tag': mtag} + def get_event_block(self): + '''Get the raw event in a blocking fashion + Slower, but decreases the possibility of dropped events + ''' + raw = self.sub.recv() + mtag, data = self.unpack(raw, self.serial) + return {'data': data, 'tag': mtag} + def iter_events(self, tag='', full=False): ''' Creates a generator that continuously listens for events