Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Functional test to demonstrate Doctrine ODM queries load inconsistent data from the database while a concurrent request is writing to the same record #1094

Closed

Conversation

blockjon
Copy link

The ODM does not save database records with embedded documents in an atomic fashion.

Even with ODM versioning, a concurrent PHP request which loads a Mongo record while another PHP request is writing the same record will load an incomplete and inconsistent version of the Mongo record into a Doctrine ODM model. This has been a repeated cause of data loss and corruption.

Repro steps:

Run this unit test:

phpunit --filter testDataConsistencyUsingEmbeddedDocuments ./tests/Doctrine/ODM/MongoDB/Tests/Functional/VersionTest.php

Result:

PHPUnit 4.1.6 by Sebastian Bergmann.

Configuration read from /srv/repos/instant-server/extrashared/mongodb-odm/phpunit.xml

F

Time: 9.38 seconds, Memory: 3.75Mb

There was 1 failure:

1) Doctrine\ODM\MongoDB\Tests\Functional\VersionTest::testDataConsistencyUsingEmbeddedDocuments
Version #2 of the versioned user object should have a phone number embedded document. However, 0 phone number embedded documents were found
Failed asserting that 0 matches expected 1.

/srv/repos/instant-server/extrashared/mongodb-odm/tests/Doctrine/ODM/MongoDB/Tests/Functional/VersionTest.php:87

FAILURES!
Tests: 1, Assertions: 3, Failures: 1.

Jonathan Block added 3 commits May 14, 2015 15:01
…atomic fashion.

Even with ODM versioning, a concurrent PHP request which loads a Mongo record while another PHP request is writing the same record will load an incomplete and inconsistent version of the Mongo record into a Doctrine ODM model. This has been a repeated cause of data loss and corruption.
@blockjon blockjon changed the title Functional test to prove Doctrine ODM queries loads inconsistent data from the database while a concurrent request is writing to the same record Functional test to prove Doctrine ODM queries load inconsistent data from the database while a concurrent request is writing to the same record May 14, 2015
@blockjon blockjon changed the title Functional test to prove Doctrine ODM queries load inconsistent data from the database while a concurrent request is writing to the same record Functional test to demonstrate Doctrine ODM queries load inconsistent data from the database while a concurrent request is writing to the same record May 15, 2015
@malarzm
Copy link
Member

malarzm commented May 19, 2015

Closing thanks to #1096

@malarzm malarzm closed this May 19, 2015
@jmikola jmikola added the Bug label May 20, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants