Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User can publish during Autosave #6648

Open
r1tsuu opened this issue Jun 5, 2024 · 2 comments · May be fixed by #11343
Open

User can publish during Autosave #6648

r1tsuu opened this issue Jun 5, 2024 · 2 comments · May be fixed by #11343

Comments

@r1tsuu
Copy link
Member

r1tsuu commented Jun 5, 2024

Link to reproduction

No response

Payload Version

3.0.0-beta.37

Node Version

20

Next.js Version

14.68canary

Describe the Bug

A user can save a document during autosave. When transactions are used (with replicaSet and haven't tested Postgres but probably too) this causes race conditions, from logs:

[14:53:45] ERROR: There was an error cleaning up old versions for the collection projects
[14:53:45] ERROR: TypeError: Cannot read properties of undefined (reading 'version')

[14:53:45] ERROR: Caused by :: Write conflict during plan execution and yielding is disabled. :: Please retry your operation or multi-document transaction.
(MongoServerError)

We should disable the publish button during autosave

Reproduction Steps

Enable autosave in a collection/global config and try to publish a document during autosave.
And important to have replicaSet when using MongoDB (mongodb atlas or configured docker compose with it) either way transactions aren't used.

Adapters and Plugins

No response

@r1tsuu r1tsuu added status: needs-triage Possible bug which hasn't been reproduced yet v3 labels Jun 5, 2024
@github-actions github-actions bot removed the status: needs-triage Possible bug which hasn't been reproduced yet label Jun 10, 2024
@denolfe denolfe removed the v3 label Nov 19, 2024
@PP-Tom
Copy link

PP-Tom commented Dec 5, 2024

ERROR: Caused by :: Write conflict during plan execution and yielding is disabled. :: Please retry your operation or multi-document transaction. is still an issue and seems to be happening more since 3.4.0 with autosave.

@cgilly2fast
Copy link

Getting this error with autosave too, happens if I click publish too soon after making an update to my document:

[21:30:29] ERROR: Caused by :: Write conflict during plan execution and yielding is disabled. :: Please retry your operation or multi-document transaction.
    err: {
      "type": "MongoServerError",
      "message": "Caused by :: Write conflict during plan execution and yielding is disabled. :: Please retry your operation or multi-document transaction.",
      "stack":
          MongoServerError: Caused by :: Write conflict during plan execution and yielding is disabled. :: Please retry your operation or multi-document transaction
.
              at Connection.sendCommand (webpack-internal:///(rsc)/../../node_modules/.pnpm/[email protected]/node_modules/mongodb/lib/cmap/connection.js:290:27)
              at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
              at async Connection.command (webpack-internal:///(rsc)/../../node_modules/.pnpm/[email protected]/node_modules/mongodb/lib/cmap/connection.js:317:26)
              at async Server.command (webpack-internal:///(rsc)/../../node_modules/.pnpm/[email protected]/node_modules/mongodb/lib/sdam/server.js:167:29)
              at async DeleteManyOperation.executeCommand (webpack-internal:///(rsc)/../../node_modules/.pnpm/[email protected]/node_modules/mongodb/lib/operations/com
mand.js:73:16)
              at async DeleteManyOperation.execute (webpack-internal:///(rsc)/../../node_modules/.pnpm/[email protected]/node_modules/mongodb/lib/operations/delete.js:
48:21)
              at async DeleteManyOperation.execute (webpack-internal:///(rsc)/../../node_modules/.pnpm/[email protected]/node_modules/mongodb/lib/operations/delete.js:
77:21)
              at async tryOperation (webpack-internal:///(rsc)/../../node_modules/.pnpm/[email protected]/node_modules/mongodb/lib/operations/execute_operation.js:199:
20)
              at async executeOperation (webpack-internal:///(rsc)/../../node_modules/.pnpm/[email protected]/node_modules/mongodb/lib/operations/execute_operation.js:
69:16)
              at async Collection.deleteMany (webpack-internal:///(rsc)/../../node_modules/.pnpm/[email protected]/node_modules/mongodb/lib/collection.js:246:16)
              at async model.Query.exec (webpack-internal:///(rsc)/../../node_modules/.pnpm/[email protected]/node_modules/mongoose/lib/query.js:4458:63)
              at async Object.deleteMany (webpack-internal:///(rsc)/../../node_modules/.pnpm/@[email protected][email protected][email protected]_monaco-editor
@[email protected]_yha243azqyq3umrsbkbsg4kqyi/node_modules/@payloadcms/db-mongodb/dist/deleteMany.js:17:5)
              at async checkDocumentLockStatus (webpack-internal:///(rsc)/../../node_modules/.pnpm/[email protected][email protected][email protected][email protected].
[email protected][email protected][email protected]/node_modules/payload/dist/utilities/checkDocumentLockStatus.js:67:5)
              at async updateByIDOperation (webpack-internal:///(rsc)/../../node_modules/.pnpm/[email protected][email protected][email protected][email protected]_re
[email protected][email protected][email protected]/node_modules/payload/dist/collections/operations/updateByID.js:117:9)
              at async Object.updateByID (webpack-internal:///(rsc)/../../node_modules/.pnpm/@[email protected]_@[email protected][email protected]_monaco-editor
@[email protected]_@b_xs3t2sptjkjswi3uod3b7u44ca/node_modules/@payloadcms/next/dist/routes/rest/collections/updateByID.js:35:15)
              at async eval (webpack-internal:///(rsc)/../../node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected]_next@
15.0.4_@b_xs3t2sptjkjswi3uod3b7u44ca/node_modules/@payloadcms/next/dist/routes/rest/index.js:760:19)
              at async AppRouteRouteModule.do (/Users/colbygilbert/Documents/Code/firmware/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected].
[email protected]_react-dom@1_4yxxxguhe67ndug5xwrtgzlyce/node_modules/next/dist/compiled/next-server/app-route.runtime.dev.js:10:33313)
              at async AppRouteRouteModule.handle (/Users/colbygilbert/Documents/Code/firmware/node_modules/.pnpm/[email protected]_@[email protected]_@opentelemetry+api@
[email protected]_react-dom@1_4yxxxguhe67ndug5xwrtgzlyce/node_modules/next/dist/compiled/next-server/app-route.runtime.dev.js:10:40382)
              at async doRender (/Users/colbygilbert/Documents/Code/firmware/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_babel-plugin
[email protected]_react-dom@1_4yxxxguhe67ndug5xwrtgzlyce/node_modules/next/dist/server/base-server.js:1455:42)
              at async responseGenerator (/Users/colbygilbert/Documents/Code/firmware/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_bab
[email protected]_react-dom@1_4yxxxguhe67ndug5xwrtgzlyce/node_modules/next/dist/server/base-server.js:1814:28)
              at async DevServer.renderToResponseWithComponentsImpl (/Users/colbygilbert/Documents/Code/firmware/node_modules/.pnpm/[email protected]_@[email protected]_@
[email protected][email protected]_react-dom@1_4yxxxguhe67ndug5xwrtgzlyce/node_modules/next/dist/server/base-server.js:1824:28)
              at async DevServer.renderPageComponent (/Users/colbygilbert/Documents/Code/firmware/node_modules/.pnpm/[email protected]_@[email protected]_@opentelemetry+a
[email protected][email protected]_react-dom@1_4yxxxguhe67ndug5xwrtgzlyce/node_modules/next/dist/server/base-server.js:2240:24)
              at async DevServer.renderToResponseImpl (/Users/colbygilbert/Documents/Code/firmware/node_modules/.pnpm/[email protected]_@[email protected]_@opentelemetry+
[email protected][email protected]_react-dom@1_4yxxxguhe67ndug5xwrtgzlyce/node_modules/next/dist/server/base-server.js:2278:32)
              at async DevServer.pipeImpl (/Users/colbygilbert/Documents/Code/firmware/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_ba
[email protected]_react-dom@1_4yxxxguhe67ndug5xwrtgzlyce/node_modules/next/dist/server/base-server.js:960:25)
              at async NextNodeServer.handleCatchallRenderRequest (/Users/colbygilb PATCH /api/queries/67569b9c921923fa2cff2cb5?draft=true&autosave=true&locale=unde
fined

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants