-
Notifications
You must be signed in to change notification settings - Fork 65
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
Transactions #163
base: master
Are you sure you want to change the base?
Transactions #163
Conversation
This reverts commit 62915a5.
// we have two different transactions attempting to update the same collection. | ||
// Here, we manually keep track of the collections involved in transactions, so that | ||
// we can avoid this deadlock. | ||
var isLocked = this._lockedCollections[collectionName] && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I mentioned in share/sharedb#689 (comment) this locking complexity may be removed entirely if we follow MongoDB's own behaviour and define cross-transactional, awaited writes to the same document to be undefined behaviour. Instead, if we just let them run in parallel, MongoDB and ShareDB can do their thing.
// Here, we manually keep track of the collections involved in transactions, so that | ||
// we can avoid this deadlock. | ||
var isLocked = this._lockedCollections[collectionName] && | ||
this._lockedCollections[collectionName] !== options.transaction; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NB: if we keep this behaviour (I don't think we should), I think MongoDB locks on a document level, so we should update this key to collectionName + id
to avoid unnecessary locking.
// current transaction | ||
// TODO: Wait for this? | ||
this.abortTransaction(this._lockedCollections[collectionName], function(error) { | ||
// TODO: Handle errors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not really sure what to do with this error, and this feels like a bit of a code smell in the architecture of transactions.
No description provided.