prooph / pdo-event-store

PDO implementation of ProophEventStore http://getprooph.org
BSD 3-Clause "New" or "Revised" License
111 stars 56 forks source link

Change order of select and count statements to fix concurrency error #207

Closed unhappyby closed 4 years ago

unhappyby commented 5 years ago

When we make read and write operations with event store at the same time we can face one problem. Making select statement before count can bring us to situation where select statement return, for example, 10 rows and count statement, which will execute after select, return 15 records. It means that we change offset to 15 and lose 5 events. So I think that we can change order of executing for this two statements and always have count less than select actual row count. This will help us go through as many lines as we get from the count statement. Diff in rows between count and select we can get from next request.

unhappyby commented 5 years ago

Its hard to reproduce in test. Because we need to read and write to event store at the same time in different processes. I think that this changes cannot break anything but they can fix this bug. If you have some questions to understand the problem feel free to ask.

coveralls commented 5 years ago

Coverage Status

Coverage remained the same at 87.076% when pulling cd3747c05da54252b053b621b97d049679ab7198 on unhappyby:event-store-statements into 423ff66107ad0531fa6ab08022a3067adcafd2cf on prooph:master.

unhappyby commented 5 years ago

Can I get any updates for this request, please? Also it would be cool if someone restart travis for passing all checks.

codeliner commented 5 years ago

Merged #208

@unhappyby As stated in the other PR your problem should be solved. Can you verify please?