-
Notifications
You must be signed in to change notification settings - Fork 13
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
[RND-644] - Investigate alternatives to MongoDB backend read-for-write-locking #304
Conversation
9be48c1
to
42e6039
Compare
Please delete writeLockReferencedDocuments() from DB.ts and the commented out references to it |
const concurrencyCollection: Collection<ConcurrencyDocument> = newClient | ||
.db(databaseName) | ||
.collection(CONCURRENCY_COLLECTION_NAME); | ||
await concurrencyCollection.createIndex({ meadowlarkId: 1, documentUuid: 1 }, { unique: true }); |
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 think these need to be split into separate indexes, since sometimes you don't have the meadowlarkId. I also wondering if they need to be unique or not. I don't think so, so think about that.
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.
Okay, I'll add or modify the tests to see what I can conclude about this. Thanks.
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.
Based on the tests I ran, I don't think we need to split the indexes. So, I am thinking we can keep it as it is.
/** | ||
* Remove the locks on in-use meadowlark documents, both those being directly updated and those being referenced. | ||
*/ | ||
export async function removeDocumentLocks( |
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 wondering if this needs to be a separate function. I think we may be able to deleteMany right after we insertMany...
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.
Hum... interesting idea, never thought of it. I'll give that a try and experiment with the tests.
@@ -0,0 +1,96 @@ | |||
// SPDX-License-Identifier: Apache-2.0 |
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.
Added some tests for the new function.
|
||
await concurrencyCollection.deleteMany( | ||
{ | ||
$and: [ |
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.
Are these $and
s necessary?
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.
Good point. Now that we have just documentUuid
, this and is not necessary.
…mance test results.
} catch (e) { | ||
expect(e).toMatchInlineSnapshot( | ||
`[MongoServerError: WriteConflict error: this operation conflicted with another operation. Please retry your operation or multi-document transaction.]`, | ||
expect(e.message).toContain( |
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.
Here it's better to use expect(e).toMatchInlineSnapshot('') that way it can be automatically updated
Description
Types of changes
Checklist