Skip to content

Conversation

@vlnach
Copy link

@vlnach vlnach commented Sep 10, 2025

No description provided.

@yunchen4 yunchen4 self-assigned this Sep 12, 2025
Copy link

@yunchen4 yunchen4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Vlad,
You are doing a good job. I left a suggestion for deadlock situation. However I didn't find your answers for mongodb exercises. I have left a comment with the correct assignment file.
Please let me know on Slack when you complete it. Thank you and have a nice weekend!

Comment on lines +19 to +26
const fromRes = await db.query(
"SELECT balance FROM account WHERE account_number = $1 FOR UPDATE",
[fromAcc]
);
const toRes = await db.query(
"SELECT balance FROM account WHERE account_number = $1 FOR UPDATE",
[toAcc]
);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: I see you want to lock the rows. It is better to always lock the rows based on a specific and predicted order, for example account ID with smaller number will be locked first. In this case the deadlock risk during high concurrency situation can be reduced. Otherwise, if two transactions happen almost the same time (for example account A->B and account B->A) the deadlock might happen.

Comment on lines +9 to +13
async function run() {
// 1) Connect
const client = new MongoClient(uri);
await client.connect();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs rework: I didn't see the answers for exercises in this file?

Copy link

@yunchen4 yunchen4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, left a comment about possible blind spot.

Comment on lines +80 to +83
const updBushes = await col.updateMany(
{ elements: "BUSHES" },
{ $set: { "elements.$": "BUSH" } }
);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not wrong, but be aware that this query only updates the first occurance of BUSHES.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants