[ARVADOS] updated: a340b9c191733087722cd4203bf0b6b76f60cbec

Git user git at public.curoverse.com
Tue Jun 14 15:48:16 EDT 2016


Summary of changes:
 services/api/lib/eventbus.rb | 24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)

       via  a340b9c191733087722cd4203bf0b6b76f60cbec (commit)
      from  3f3b57c67af8967d466cf69b4c8e41885eee13c8 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit a340b9c191733087722cd4203bf0b6b76f60cbec
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date:   Tue Jun 14 15:48:08 2016 -0400

    9388: Add ws.notify_queue to ensure that notifies occurring during "catch up"
    will get delivered in the correct order after catch up completes.

diff --git a/services/api/lib/eventbus.rb b/services/api/lib/eventbus.rb
index cce6798..eb7750f 100644
--- a/services/api/lib/eventbus.rb
+++ b/services/api/lib/eventbus.rb
@@ -16,6 +16,7 @@ module Faye
     attr_accessor :last_log_id
     attr_accessor :filters
     attr_accessor :sent_ids
+    attr_accessor :notify_queue
   end
 end
 
@@ -78,14 +79,18 @@ class EventBus
         cond_out = []
         param_out = []
 
-        if !ws.last_log_id.nil?
+        if not notify_id.nil?
+          ws.notify_queue.unshift notify_id
+        end
+
+        if not ws.last_log_id.nil?
           # We are catching up from some starting point.
           cond_id = "logs.id > ?"
           param_out << ws.last_log_id
-        elsif !notify_id.nil?
-          # Get new row being notified.
+        elsif ws.notify_queue.length > 0
+          # Get next row being notified.
           cond_id = "logs.id = ?"
-          param_out << notify_id
+          param_out << ws.notify_queue.pop
         else
           # No log id to start from, nothing to do, return
           return
@@ -121,7 +126,7 @@ class EventBus
             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
+            # record ids only when sending "catchup" messages, not notifies
             ws.sent_ids << l.id
           end
           lastid = l.id
@@ -134,12 +139,18 @@ class EventBus
           # reported by current query)
           ws.last_log_id = lastid
           EventMachine::next_tick do
-            push_events ws, notify_id
+            push_events ws, nil
           end
         elsif !ws.last_log_id.nil?
           # Done catching up
           ws.last_log_id = nil
         end
+
+        if ws.notify_queue.length > 0
+          EventMachine::next_tick do
+            push_events ws, nil
+          end
+        end
       end
     rescue ArgumentError => e
       # There was some kind of user error.
@@ -232,6 +243,7 @@ class EventBus
     ws.filters = []
     ws.last_log_id = nil
     ws.sent_ids = Set.new
+    ws.notify_queue = Array.new
 
     # Subscribe to internal postgres notifications through @channel.  This will
     # call push_events when a notification comes through.

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list