9388: Only record log ids sent during "catch up" phase, to avoid duplicates.
authorPeter Amstutz <peter.amstutz@curoverse.com>
Tue, 14 Jun 2016 17:28:32 +0000 (13:28 -0400)
committerPeter Amstutz <peter.amstutz@curoverse.com>
Tue, 14 Jun 2016 17:28:32 +0000 (13:28 -0400)
services/api/lib/eventbus.rb

index 58188efa3616280552d193924ed427fa977327c6..cce6798cb0e950dea9412ab6ea601c1897cbf91e 100644 (file)
@@ -116,9 +116,14 @@ class EventBus
 
         lastid = nil
         logs.limit(limit).each do |l|
-          if ws.sent_ids.add?(l.id) != nil
+          if not ws.sent_ids.include?(l.id)
+            # only send if not a duplicate
             ws.send(l.as_api_response.to_json)
           end
+          if not ws.last_log_id.nil?
+            # only record ids from "catchup" messages and not notifies
+            ws.sent_ids << l.id
+          end
           lastid = l.id
           count += 1
         end
@@ -135,9 +140,6 @@ class EventBus
           # Done catching up
           ws.last_log_id = nil
         end
-      elsif !notify_id.nil?
-        # No filters set up, so just record the sequence number
-        ws.last_log_id = notify_id
       end
     rescue ArgumentError => e
       # There was some kind of user error.