{"record":{"id":"ef4f8fe8e5f31330","repo":"payloadcms/payload","slug":"global-document-with-slug-globalslug-is-curre","errorCode":null,"errorMessage":"Global document with slug \"${globalSlug}\" is currently locked by another user and cannot be modified.","messagePattern":"Global document with slug \"(.+?)\" is currently locked by another user and cannot be modified\\.","errorType":"exception","errorClass":"Locked","httpStatus":423,"severity":"warning","filePath":"packages/payload/src/utilities/checkDocumentLockStatus.ts","lineNumber":94,"sourceCode":"\n    // If there's a locked document, check lock conditions\n    const lockedDoc = lockedDocumentResult?.docs[0]\n    if (lockedDoc) {\n      const lastEditedAt = new Date(lockedDoc?.updatedAt).getTime()\n      const now = new Date().getTime()\n\n      const lockDuration =\n        typeof lockDocumentsProp === 'object' ? lockDocumentsProp.duration : lockDurationDefault\n\n      const lockDurationInMilliseconds = lockDuration * 1000\n      const currentUserId = req.user?.id\n\n      // document is locked by another user and the lock hasn't expired\n      if (\n        lockedDoc.user?.value !== currentUserId &&\n        now - lastEditedAt <= lockDurationInMilliseconds\n      ) {\n        throw new Locked(finalLockErrorMessage)\n      }\n    }\n  }\n\n  // Perform the delete operation regardless of overrideLock status\n  await payload.db.deleteMany({\n    collection: lockedDocumentsCollectionSlug,\n    // Not passing req fails on postgres\n    req: payload.db.name === 'mongoose' ? undefined : req,\n    where: lockedDocumentQuery,\n  })\n}\n","sourceCodeStart":76,"sourceCodeEnd":107,"githubUrl":"https://github.com/payloadcms/payload/blob/00c58b35c0ed348ddc22daabf467b139727214fd/packages/payload/src/utilities/checkDocumentLockStatus.ts#L76-L107","documentation":"A `Locked` error thrown by `checkDocumentLockStatus` when a global is being modified without holding the lock. Another user lock entry exists for this `globalSlug` with a different `user.value` and an `updatedAt` within the configured lock duration.","triggerScenarios":"A write to a global (e.g. `payload.updateGlobal`) where `overrideLock` is `false`, the global `lockDocuments` is not `false`, and a recent lock entry exists in the `locked-documents` collection for this `globalSlug` owned by a different user.","commonSituations":"Two admin users editing the same global (e.g. site settings) concurrently; a stale lock from a user who closed the browser tab; automated global updates colliding with manual admin edits; long lock durations preventing timely automated writes.","solutions":["Wait for the lock to expire or have the locking user release it by navigating away / saving.","Pass `overrideLock: true` in the `updateGlobal` Local API call for automated/forced writes.","Configure `lockDocuments: false` on the global config if locking is not desired for it.","Reduce the lock `duration` if locks persist too long."],"exampleFix":"// before\nawait payload.updateGlobal({\n  slug: 'siteSettings',\n  data: { title: 'New Site' },\n  // blocked by another user active lock\n})\n\n// after\nawait payload.updateGlobal({\n  slug: 'siteSettings',\n  data: { title: 'New Site' },\n  overrideLock: true,\n})","handlingStrategy":"try-catch","validationCode":"// Before updating a global, check for active locks\nconst locks = await payload.find({\n  collection: 'payload-locked-documents',\n  where: { globalSlug: { equals: globalSlug } },\n  depth: 1,\n})\nconst lock = locks.docs[0]\nif (lock && lock.user?.value !== currentUserId && Date.now() - new Date(lock.updatedAt).getTime() < duration * 1000) {\n  throw new Error('Global is locked')\n}","typeGuard":null,"tryCatchPattern":"try {\n  await payload.updateGlobal({ slug: globalSlug, data, overrideLock: false })\n} catch (e) {\n  if (e.name === 'Locked') {\n    // wait, notify user, or use overrideLock: true for automated writes\n  } else throw e\n}","preventionTips":["For automated global writes, pass overrideLock: true.","Set lockDocuments: false on globals that are exclusively automated.","Show lock status in the admin UI for collaborative global editing.","Use a reasonable lock duration to avoid stale locks."],"tags":["locking","concurrency","global","admin"],"backgroundTag":null,"analyzedSha":"00c58b35c0ed348ddc22daabf467b139727214fd","analyzedAt":"2026-08-12T20:45:03.758Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}