mboudreau / Alternator

A mock DynamoDB that runs locally for testing purposes - DEPRECATED, PLEASE USE DYNAMODB LOCAL: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBLocal.html
Apache License 2.0
78 stars 39 forks source link

Synchronization locking needed to support thread-safety on Inserts #58

Closed rrutt closed 11 years ago

rrutt commented 11 years ago

When using Alternator for development I was pre-loading some test data via Node.js which is able to spawn several simultaneous worker threads calling the .putItem method.

These test records had several different Range Key values within each Hash Key value. A race condition caused more than one itemRangeGroup collection to be associated with a given Hash Key. Only the first collection remained "visible" to future queries against that Hash Key. The records within the other collection became orphaned and were no longer reachable.

A strategically placed synchronization lock should resolve this.

In the meantime, application developers should consider serializing .putItem method calls during data load operations.

rrutt commented 11 years ago

I should be able to fix this in the next week or two.

rrutt commented 11 years ago

If anyone encounters this thread-safety issue prior to this pull request being merged, the revision is available in this branch of my forked repository:

https://github.com/rrutt/Alternator/tree/synchronized-dbhandler-methods