Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-38048

Allow an update query to be run always at the end of the session

    • Type: Icon: New Feature New Feature
    • Resolution: Won't Fix
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None

      I would like to ask for a feature which would allow me to specify an update query to be always run at the end of the session. Even if the client dies/disconnects.

      I have a schema design where I have two collections, Document and Step. Each Document can have multiple Steps. I use two collections because size and number of Steps belonging to one Document can grow over the 16 MB limit so I cannot include them inside one Document.

      In most operations I just add more Step documents. But some operations require changing many Step documents at once and during that time no new documents should be added for a particular Document. (Imagine like rewriting git history.) For this, I have a field on Document which serves as a lock. The logic is as follows:

      • Set lock on Document.
      • Add a Step document, or modify multiple Step documents.
      • Release lock on Document.

      The problem is that if the client dies/disconnects before releasing a lock, I have a problem. It seems MongoDB transactions would not help me here with an overall problem. They can help with making modification of multiple Step documents all at once or none. But during transaction other Step documents could still be added. Which I would like to prevent.

      So I think that what would solve my problem is that I could set an update query to be run at the end of the session. Then I could do:

      • Start session.
      • Set lock on Document.
      • Set release lock query on Document to be run at the end of session.
      • Start transaction.
      • Modify multiple Step documents.
      • Commit transaction.
      • End session.

       

            Assignee:
            daniel.hatcher@mongodb.com Danny Hatcher (Inactive)
            Reporter:
            mitar NOVALUE Mitar
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: