mirror of
https://github.com/outline/outline.git
synced 2026-12-04 02:20:17 +03:00
fix: Add row lock in documentUpdater (#13108)
This commit is contained in:
1 parent
77b01f11fc
commit
f2c44f8732
1 file changed
+13
@@ -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();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user