payload icon indicating copy to clipboard operation
payload copied to clipboard

Documents showing locked by current user

Open tylandavis opened this issue 1 year ago • 4 comments

Link to reproduction

No response

Environment Info

Binaries: Node: 22.6.0 npm: 10.8.2 Yarn: 1.22.22 pnpm: 9.7.1 Relevant Packages: payload: 3.0.0-beta.111 next: 15.0.0-canary.173 @payloadcms/db-mongodb: 3.0.0-beta.111 @payloadcms/email-nodemailer: 3.0.0-beta.111 @payloadcms/graphql: 3.0.0-beta.111 @payloadcms/live-preview: 3.0.0-beta.111 @payloadcms/live-preview-react: 3.0.0-beta.111 @payloadcms/next/utilities: 3.0.0-beta.111 @payloadcms/plugin-cloud: 3.0.0-beta.111 @payloadcms/plugin-cloud-storage: 3.0.0-beta.111 @payloadcms/plugin-form-builder: 3.0.0-beta.111 @payloadcms/plugin-nested-docs: 3.0.0-beta.111 @payloadcms/plugin-redirects: 3.0.0-beta.111 @payloadcms/plugin-seo: 3.0.0-beta.111 @payloadcms/richtext-lexical: 3.0.0-beta.111 @payloadcms/storage-vercel-blob: 3.0.0-beta.111 @payloadcms/translations: 3.0.0-beta.111 @payloadcms/ui/shared: 3.0.0-beta.111 react: 19.0.0-rc-3edc000d-20240926 react-dom: 19.0.0-rc-3edc000d-20240926 Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 23.5.0: Wed May 1 20:14:38 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T6020 Available memory (MB): 16384 Available CPU cores: 12

Describe the Bug

When opening documents, locked document warning message is showing, saying that the document is being edited by the current user. This is happening for all documents, regardless of actual locked status, and even for a brand new user who has never edited documents before.

Video of issue: https://github.com/user-attachments/assets/63fbdd4d-aeab-488c-812f-39eeda231512

Reproduction Steps

  • Log into payloadcms.com/admin.
  • Navigate to document's edit view.
  • See modal that document is locked by you.

Adapters and Plugins

db-mongodb, storage-vercel-blob, richtext-lexical, plugin-seo, plugin-redirects, plugin-form-builder, email-nodemailer

tylandavis avatar Oct 07 '24 20:10 tylandavis

I'm getting this as well, with postgres.

drewlonious avatar Oct 07 '24 22:10 drewlonious

With SQLite (same environment) the lock documents from another user will stay locked indefinitely, until you 'take over'. Last test it stayed locked for 5 hours with no one logging in.

mikecebul avatar Oct 08 '24 03:10 mikecebul

Hey @drewlonious and @mikecebul,

Thank you both for reporting this issue.

After reviewing the issue, it seems that the initial document locking problem may be related to a recent change made in the MongoDB adapter, where relationships are now stored as ObjectIDs instead of strings. This caused a bug in certain beta versions (v3.0.0-beta.108 to around v3.0.0-beta.110), leading to stale documents appearing twice in the list view. This bug has since been resolved in the release (v3.0.0-beta.111).

However @drewlonious, since you mentioned that this issue also appeared in your Postgres project, could you please provide additional reproduction steps or describe how you encountered the issue?

In the meantime, for those who encountered this with MongoDB, we recommend saving a new version of each document that appears as a duplicate. Additionally, clearing out any entries from the payload-locked-documents collection in your database should remove any stale locks caused by these duplicates.

We encountered the same issue in our website CMS and found that these steps resolved it. If you run into any issues with this process or need further clarification, please feel free to reach out, and I’d be happy to assist.

@Mikecebul – Regarding the behavior you're experiencing: Currently, this is by design. The document edit view relies on an unmount function to remove the lock when a user navigates away. However, if a page refresh occurs or the user steps away without leaving the document, the unmount function doesn’t get triggered, and the lock remains.

We’re actively exploring alternative solutions to address this scenario, but for now, the Take Over option is provided to ensure that other users aren't blocked by stale locks. Additionally, the overrideLock option in the Local API can help manage updates on documents that remain locked. I hope this explanation helps clarify the situation.

PatrikKozak avatar Oct 09 '24 18:10 PatrikKozak

That makes sense, thanks for the explanation.

mikecebul avatar Oct 09 '24 18:10 mikecebul

Fixed with #8744

PatrikKozak avatar Oct 16 '24 18:10 PatrikKozak

🚀 This is included in version v3.0.0-beta.116

github-actions[bot] avatar Oct 17 '24 13:10 github-actions[bot]

After reviewing the issue, it seems that the initial document locking problem may be related to a recent change made in the MongoDB adapter, where relationships are now stored as ObjectIDs instead of strings. This caused a bug in certain beta versions (v3.0.0-beta.108 to around v3.0.0-beta.110), leading to stale documents appearing twice in the list view. This bug has since been resolved in the release (v3.0.0-beta.111).

However @drewlonious, since you mentioned that this issue also appeared in your Postgres project, could you please provide additional reproduction steps or describe how you encountered the issue?

In the meantime, for those who encountered this with MongoDB, we recommend saving a new version of each document that appears as a duplicate. Additionally, clearing out any entries from the payload-locked-documents collection in your database should remove any stale locks caused by these duplicates.

We encountered the same issue in our website CMS and found that these steps resolved it. If you run into any issues with this process or need further clarification, please feel free to reach out, and I’d be happy to assist.

@PatrikKozak I am using release v3.0.0-beta.116 with MongoDB (local). Document locks are added immediately after changing a value in the UI (i.e., on blur/change). The screenshot below appears and a document is added to payload-locked-documents.

Rolling back to 3.0.0-beta.107 resolves the issue, as well as setting lockDocuments: false in each CollectionConfig.

Image Image

BrianJM avatar Oct 18 '24 13:10 BrianJM

This issue has been automatically locked. Please open a new issue if this issue persists with any additional detail.

github-actions[bot] avatar Oct 20 '24 04:10 github-actions[bot]