Skip to content

Allow atomic $set for hash type fields #1288

Open
@tux-rampage

Description

@tux-rampage

The hash type field does not allow atomic updates for its fields. Only the whole field is updated.
Much as in #1286 this causes data loss when a Document is updated in multiple requests/threads at the same time.

Request 1:

// Assume $object is managed by the document manager and the "hash"
// Property is mapped as field type "hash" 
$object->hash['somekey'] = 'foo';
$dm->flush($object);

Request 2:

// Assume $object is the same as in Request 1 (Same _id)
// and was loaded before changes in Request 1 were flushed
$object->hash['someotherkey'] = 'bar';
$dm->flush();

Depending on which flush occurs last, the resulting hash in mongo db will either be { "somekey": "foo" } or { "someotherkey": "bar" }, but never { "somekey": "foo", "someotherkey": "bar" } (which would be expected, since the hash was extended and not replaced in code).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions