[Change Streams] Allow to recognize last change of transaction

XMLWordPrintableJSON

    • Query Execution
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      I'm using Mongo change streams to send database changes in realtime from my node backend to an angular webapplication.

      When I mutate a lot of data rows using a transaction, I want to send those changes to the client as one accumulated change and not one by one.

      To achive that, I queue new changes if they are part of a transaction.

      And here starts my problem:

      How to identify the last change event of a transaction? At the moment I set a timeout and wait if another change with the same lsid arrives within the timeout. If not I consider the transaction complete.

      Aside from being a very ugly hack, this has two severe downside:

      • If the timeout is too short, I can't rely on the transaction changes to arrive fast enough
      • The timeouts accumulate and lead (in case of transactions affecting a lot of documents) to very high response times on the client side

      I think the best solution would be to either set a flag on the change event (something like a "last" or "finished" boolean in addition to the lsid) or emit a specific event in the stream after a transaction's last change.

      If anybody has already solved that issue in another fashion, please let me know.

      Thanks very much!

              Assignee:
              [DO NOT USE] Backlog - Query Execution
              Reporter:
              Stefan Holzapfel
              Votes:
              4 Vote for this issue
              Watchers:
              25 Start watching this issue

                Created:
                Updated: