Uploaded image for project: 'Spring Data MongoDB'
  1. Spring Data MongoDB
  2. DATAMONGO-622

An unversioned object should be created using insert(…) instead of save.

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.2 GA
    • Fix Version/s: 1.2.1, 1.3 M1
    • Component/s: Core
    • Labels:
      None

      Description

      MongoTemplate.doSaveVersioned(…) uses doSave(…) to store an unversioned object. It should rather use doInsert(…) to avoid race conditions on concurrent inserts.

        Activity

        Hide
        ayushsoni Ayush Soni added a comment -

        Hi Team - I think fixing this issue created another bug (DATAMONGO-1051). If it would have been doSave(…) only then @Version could have been used for already existing entities as well, As doSave(..) internally decides on the basis of Unique Id that to do an Insert or Update on the same.
        But currently if a @version is added to an existing entity it calls doInsert(..) over it according to the Null Check in MongoTemplate.doSaveVersioned(…)
        One work around discussed on that issue is to add a default version values in older documents but updating millions n millions of older records in a production environment is not a feasible solution if they are growing continously.

        Thanks! - Please think on this.

        Show
        ayushsoni Ayush Soni added a comment - Hi Team - I think fixing this issue created another bug (DATAMONGO-1051) . If it would have been doSave(…) only then @Version could have been used for already existing entities as well, As doSave(..) internally decides on the basis of Unique Id that to do an Insert or Update on the same. But currently if a @version is added to an existing entity it calls doInsert(..) over it according to the Null Check in MongoTemplate.doSaveVersioned(…) One work around discussed on that issue is to add a default version values in older documents but updating millions n millions of older records in a production environment is not a feasible solution if they are growing continously. Thanks! - Please think on this.

          People

          • Assignee:
            olivergierke Oliver Gierke
            Reporter:
            olivergierke Oliver Gierke
            Last updater:
            Ayush Soni
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: