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

feature/atomic-many-updates flaw - Functional test to demonstrate Doctrine ODM queries load inconsistent data from the database while a concurrent request is writing to the same record #1095

Conversation

blockjon
Copy link

This PR's branch has linage to feature/atomic-many-updates. I created it to demonstrate that the atomic feature that you are shooting for seems not to solve for a key data inconsistency problem I am grappling with.

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: 315 ms, Memory: 3.25Mb

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:84

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

@blockjon blockjon changed the title feature/atomic-many-updates flaw - Functional test to prove Doctrine ODM queries load inconsistent data from the database while a concurrent request is writing to the same record feature/atomic-many-updates flaw - 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 since we introduced another PR for the feature and feature/atomic-many-updates is not relevant

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

Successfully merging this pull request may close these issues.

None yet

2 participants