X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/21ccdae70baaca0c7aeca8542f2a0a431f06c313..e3e54264e8bc767e1ec773cff4e5bdf4c4934a36:/services/api/lib/eventbus.rb diff --git a/services/api/lib/eventbus.rb b/services/api/lib/eventbus.rb index a0c0b272e7..1754fc0ae9 100644 --- a/services/api/lib/eventbus.rb +++ b/services/api/lib/eventbus.rb @@ -51,7 +51,9 @@ class EventBus # Push out any pending events to the connection +ws+ # +notify_id+ the id of the most recent row in the log table, may be nil # - # This accepts a websocket and a notify_id (this is the row id from Postgres LISTEN/NOTIFY, it may nil) + # This accepts a websocket and a notify_id (this is the row id from Postgres + # LISTEN/NOTIFY, it may be nil if called from somewhere else) + # # It queries the database for log rows that are either # a) greater than ws.last_log_id, which is the last log id which was a candidate to be sent out # b) if ws.last_log_id is nil, then it queries rows starting with notify_id @@ -122,7 +124,9 @@ class EventBus # Number of rows returned was capped by limit(), we need to schedule # another query to get more logs (will start from last_log_id # reported by current query) - @channel.push nil + EventMachine::schedule do + push_events ws, nil + end elsif !notify_id.nil? and (ws.last_log_id.nil? or notify_id > ws.last_log_id) # Number of rows returned was less than cap, but the notify id is # higher than the last id visible to the client, so update last_log_id @@ -248,6 +252,9 @@ class EventBus @channel.push payload.to_i end end + rescue NoMemoryError + EventMachine::stop_event_loop + abort "Out of memory" ensure # Don't want the connection to still be listening once we return # it to the pool - could result in weird behavior for the next