fix: Add row lock in documentUpdater (#13108)

This commit is contained in:
Tom Moor authored and GitHub committed 2026-07-23 19:52:41 -04:00
1 parent 77b01f11fc
commit f2c44f8732
1 file changed
+13
+13
View File
@@ -65,6 +65,19 @@ export default async function documentUpdater(
const { transaction } = ctx.state;
const cId = collectionId || document.collectionId;
// Serialize concurrent updates to the same document by taking a row-level
// lock before mutating. The wait is already bounded by the transaction's
// statement_timeout.
if (transaction) {
await Document.unscoped().findOne({
attributes: ["id"],
where: { id: document.id },
transaction,
lock: transaction.LOCK.UPDATE,
paranoid: false,
});
}
if (title !== undefined) {
document.title = title.trim();
}