819. Avoid long transaction — concurrency case 4

DBMS Published Updated 0 Views Verified
Write or choose the MySQL approach that reduces race conditions, lock waits or deadlocks in this scenario.
Looking for the latest Sarkari Result 2026 updates? Check the latest government exam results, merit lists and result updates on Sarkari Resultess.
Sarkari Resultess
Questions & Answers

Answer & Explanation

4 Answers
Verified

Option A

Keep a transaction open while doing network calls.
Additional Explanation
This option is incorrect for the stated requirement.
Sarkari Resultess
Editorial Answer 1
Verified

Option B

Lock rows in random order in each worker.
Additional Explanation
This option is incorrect for the stated requirement.
Sarkari Resultess
Editorial Answer 2
Verified Correct Answer

Option C

START TRANSACTION; SELECT id FROM tasks WHERE id=10 FOR UPDATE; UPDATE tasks SET status='processing' WHERE id=10; COMMIT;
Additional Explanation
Correct implementation. Prefer parameterized queries in application code, validate affected rows for UPDATE/DELETE, and use transactions for related writes.
Sarkari Resultess
Editorial Answer 3
Verified

Option D

Use SELECT without a transaction for a critical read-modify-write sequence.
Additional Explanation
This option is incorrect for the stated requirement.
Sarkari Resultess
Editorial Answer 4