ExportXMLWordPrintableJSON

    • Type: New Feature
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • Ruby Drivers
    • None
    • None
    • None
    • None
    • None
    • None

      The current Mongoid persistence layer, modeled after ActiveRecord, lacks support for nested transactions and save points, which are necessary for maintaining data integrity in a relational model. In the absence of this safety net in MongoDB, several issues arise: data inconsistency, where referenced association assignments (like has_one, has_many) write immediately before save is called, allowing invalid data to be persisted. Additionally, satellite operations (such as touch and counter cache) trigger many independent database round trips as after_save callbacks. This fragmented approach means there's no single moment for coherent validation of the document's full intended state before writing, and a failure during the many writes leaves the database in a partially-written state with no automatic rollback.

      To address these challenges, the goal for a new major version of Mongoid is to introduce a changeset-backed persistence layer. This new layer will defer all database writes, including those from referenced association assignments, until the save call. This deferral allows for the validation of the complete intended state of a document and its pending associated documents before any write is issued. Furthermore, the system will submit all changes as a single bulk operation (a changeset), which maximizes atomicity and drastically reduces the number of database round trips by merging satellite operations into the primary write.

            Assignee:
            Jamis Buck
            Reporter:
            Alex Bevilacqua
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: