-
Notifications
You must be signed in to change notification settings - Fork 2k
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
DocumentDB: cursur within transaction not supported, rest API 500 error above 101 results #4438
Comments
Sorry for the delay. You might consider using the new |
We are having the same problem. Any possible solution that doesn't require disabling transactions? |
@DanRibbens or, is there a way to disable transactions only in a specific (local or REST) API call? Our current workaround would be to use a custom endpoint which fetches all documents using the db adapter in order to not use a transaction, but this way we still need to deal with authorization. |
@DanRibbens Based on our analysis, this issue seems to stem from the interplay between enabled transactions in Payload CMS, the batchSize setting in Mongoose, and the transaction limitations within AWS DocumentDB. We require transactions to be enabled for certain hooks to function as expected, ensuring that changes can be reliably rolled back in case of errors. Therefore, disabling transactions entirely is not a viable option for us. By default, Mongoose uses a batchSize of 101. When a query in DocumentDB returns more than 101 items, Mongoose resorts to using a cursor, which is not supported within transactions in DocumentDB. We see the following potential solutions:
These solutions are applicable in cases where we can directly use the DatabaseAdapter instead of Payload's Local/GraphQL/REST APIs. However, it would be ideal if Payload could provide an option to disable cursor usage within transactions and handle such cases internally. |
This all makes sense @tak-amboss. Thank you for the analysis on this. I'll get back to you after I do some research into the feasibility for disabling the cursor as a feature flag for the db adapter. |
@r1tsuu and I just talked through this issue and possible solutions. Before we go ahead with a new solution to this problem, we're thinking this is already mitigated by the changes made in v3. In the beta currently, I've made it so that any read operations don't call initTransaction (they'll use a transaction if one already exists on the It could be that you also get this when trying to update > 100 docs, in which case we may need a batching mechanism or some custom flags around cursors built into payload or the database adapter. Can anyone confirm that this is not an issue with documentDB on a recent version of v3 beta of Payload? |
@DanRibbens that should fix a lot of the issues, but this will still be an issue in situations where you want to |
We could implement some batching logic into all find operations after/to this PR #9594 to |
@r1tsuu the workaround that we have used for now was to increase the |
Link to reproduction
No response
Describe the Bug
When calling a rest endpoint with a limit higher then 101 and more then 101 results, DocumentDB throws the following error:
MongoServerError: Feature not supported: cursor within transaction. Try increasing the batchsize
This seems to be causes by a limitation of Documentdb
To Reproduce
{"errors":[{"message":"Something went wrong."}]}
Payload Version
2.3.1
Adapters and Plugins
@payloadcms/db-mongodb
The text was updated successfully, but these errors were encountered: