diff --git a/services/real-time/app/coffee/DocumentUpdaterManager.coffee b/services/real-time/app/coffee/DocumentUpdaterManager.coffee index 0c8d864ce8..ab893aa47f 100644 --- a/services/real-time/app/coffee/DocumentUpdaterManager.coffee +++ b/services/real-time/app/coffee/DocumentUpdaterManager.coffee @@ -55,10 +55,8 @@ module.exports = DocumentUpdaterManager = queueChange: (project_id, doc_id, change, callback = ()->)-> jsonChange = JSON.stringify change doc_key = "#{project_id}:#{doc_id}" - multi = rclient.multi() - multi.rpush Keys.pendingUpdates({doc_id}), jsonChange - multi.sadd "DocsWithPendingUpdates", doc_key - multi.rpush "pending-updates-list", doc_key - multi.exec (error) -> + # Push onto pendingUpdates for doc_id first, because once the doc updater + # gets an entry on pending-updates-list, it starts processing. + rclient.rpush Keys.pendingUpdates({doc_id}), jsonChange, (error) -> return callback(error) if error? - callback() + rclient.rpush "pending-updates-list", doc_key, callback diff --git a/services/real-time/test/acceptance/coffee/ApplyUpdateTests.coffee b/services/real-time/test/acceptance/coffee/ApplyUpdateTests.coffee index bb2df04ae2..0acc41cb70 100644 --- a/services/real-time/test/acceptance/coffee/ApplyUpdateTests.coffee +++ b/services/real-time/test/acceptance/coffee/ApplyUpdateTests.coffee @@ -46,11 +46,6 @@ describe "applyOtUpdate", -> rclient.lrange "pending-updates-list", 0, -1, (error, [doc_id]) => doc_id.should.equal "#{@project_id}:#{@doc_id}" done() - - it "should add the doc to the pending updates set in redis", (done) -> - rclient.sismember "DocsWithPendingUpdates", "#{@project_id}:#{@doc_id}", (error, isMember) => - isMember.should.equal 1 - done() it "should push the update into redis", (done) -> rclient.lrange "PendingUpdates:#{@doc_id}", 0, -1, (error, [update]) => @@ -145,11 +140,6 @@ describe "applyOtUpdate", -> rclient.lrange "pending-updates-list", 0, -1, (error, [doc_id]) => doc_id.should.equal "#{@project_id}:#{@doc_id}" done() - - it "should add the doc to the pending updates set in redis", (done) -> - rclient.sismember "DocsWithPendingUpdates", "#{@project_id}:#{@doc_id}", (error, isMember) => - isMember.should.equal 1 - done() it "should push the update into redis", (done) -> rclient.lrange "PendingUpdates:#{@doc_id}", 0, -1, (error, [update]) => diff --git a/services/real-time/test/unit/coffee/DocumentUpdaterManagerTests.coffee b/services/real-time/test/unit/coffee/DocumentUpdaterManagerTests.coffee index c693880e39..e6f9b2098b 100644 --- a/services/real-time/test/unit/coffee/DocumentUpdaterManagerTests.coffee +++ b/services/real-time/test/unit/coffee/DocumentUpdaterManagerTests.coffee @@ -123,10 +123,7 @@ describe 'DocumentUpdaterManager', -> "range":{"start":{"row":2,"column":2},"end":{"row":2,"column":3}}, "text":"e" } - @rclient.multi = sinon.stub().returns @rclient - @rclient.exec = sinon.stub().callsArg(0) - @rclient.rpush = sinon.stub() - @rclient.sadd = sinon.stub() + @rclient.rpush = sinon.stub().yields() @callback = sinon.stub() describe "successfully", -> @@ -143,14 +140,9 @@ describe 'DocumentUpdaterManager', -> .calledWith("pending-updates-list", "#{@project_id}:#{@doc_id}") .should.equal true - it "should push the doc id into the pending updates set", -> - @rclient.sadd - .calledWith("DocsWithPendingUpdates", "#{@project_id}:#{@doc_id}") - .should.equal true - - describe "with error connecting to redis during exec", -> + describe "with error talking to redis during rpush", -> beforeEach -> - @rclient.exec = sinon.stub().callsArgWith(0, new Error("something went wrong")) + @rclient.rpush = sinon.stub().yields(new Error("something went wrong")) @DocumentUpdaterManager.queueChange(@project_id, @doc_id, @change, @callback) it "should return an error", ->