Announcement Announcement Module
No announcement yet.
Mongodb: suspected bugs in @Version management Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Mongodb: suspected bugs in @Version management

    I'm looking into the @Version management in spring-data-mongo 1.2.0.RELEASE.
    The design is great, convenient and transparent, but I suspect some bugs:

    1) When a @Version'ed object is updated, the "collectionName" parameter is ignored, and instead the default collection is used (based on class name).
    This happens in MongoTemplate.doSaveVersioned():
    - if version is not null, it calls updateFirst(query, update, objectToSave.getClass());
    - while it should call doUpdate(collectionName, query, update, objectToSave.getClass(), false, false);

    2) Type mismatch in MongoTemplate.initializeVersionProperty():
    It sets version to '0', while it should be long: '0L'

    3) Consideration for a "race" of two inserts":
    Assume "user1" has successfully inserted a new DBObject.
    Then another "user2" tries to insert a new DBObject with the same ID (and version=null as typical for inserts).
    I'd expect user2 to fail, but instead he performs an update. That's in MongoTemplate.doSaveVersioned():
    if version is null, it calls doSave(...). I believe it should call doInsert(...) which would properly fail on 'duplicate id'.
    But admittedly it's a non-trivial scenario and I'd appreciate more opinions on it.

    Thanks very much

  • #2
    1) DATAMONGO-620 [0] - Fix in master [1]
    2) DATAMONGO-621 [2] - Fix in master [3]
    3) DATAMONGO-622 [4] - Fix in master [5]

    All fixes have been back-ported to the 1.2.x branch. Thanks for spotting those issues!



    • #3
      Thanks very much, plus extra thanks for the quick response.