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

Transactions enabled by default on REST requests #6019

Closed
fbeiger opened this issue Sep 3, 2019 · 4 comments
Closed

Transactions enabled by default on REST requests #6019

fbeiger opened this issue Sep 3, 2019 · 4 comments

Comments

@fbeiger
Copy link

fbeiger commented Sep 3, 2019

Issue Description

I updated parse-server to the 3.8.0 release (which include a newest addition of transactions).

I found that transactions are enabled by default when performing a REST request (either from the JS client, parse-dashboard, or a simple POSTMAN), without using the transaction: true parameter in the payload.

Although, cloud-code seem to work as expected, as I am still able to perform operations.

Regarding this I have several questions:

  • Is it the expected behaviour?
  • If so, is it possible to disable transactions globally (when setting up the parse-server for example)?

Steps to reproduce

Perform a PUT query on whatever object (with or without MasterKey)
Example with a session token:

curl -X PUT \
  <PARSE_SERVER_URL>/parse/classes/<YOUR_CLASS>/<OBJECT_ID> \
  -H 'Content-Type: application/json' \
  -H 'Host: <PARSE_SERVER_URL>' \
  -H 'X-Parse-Application-Id: <YOUR_APP_ID>' \
  -H 'X-Parse-REST-API-Key: <YOUR_REST_KEY>' \
  -H 'X-Parse-Session-Token: <YOUR_TOKEN>' \
  -d '{
  "myAttribute":"myValue"
}'

Expected Results

To update object's attribute with corresponding value.

Actual Outcome

Instead, I have a status 500 response with this body:

{
    "code": 1,
    "message": "Internal server error."
}

And this error server-side:

error: Uncaught internal server error.Transaction numbers are only allowed on storage engines that support document-level locking

Environment Setup

  • Server

    • parse-server version (Be specific! Don't say 'latest'.) : 3.8.0
    • Operating System: Heroku
    • Hardware: Heroku
    • Localhost or remote server? (AWS, Heroku, Azure, Digital Ocean, etc): Heroku
  • Database

    • MongoDB version: 3.6.12
    • Storage engine: MMAPv1
    • Hardware: unknown
    • Localhost or remote server? (AWS, mLab, ObjectRocket, Digital Ocean, etc): mLab

Logs/Trace

error: Uncaught internal server error.Transaction numbers are only allowed on storage engines that support document-level locking
@davimacedo
Copy link
Member

The transaction should only be opened when using the transaction: true option through the batch route. I will write a test case to ensure that. In the meantime, can you please take a look in the following issue?

#5983

@davimacedo
Copy link
Member

@fbeiger see this PR: #6022

I added many tests and it seems to be working as expected. Feel free to add more tests to this PR in order to reproduce the problem.

Have you tried the approach of the other issue I sent you?

@fbeiger
Copy link
Author

fbeiger commented Sep 4, 2019

Hi @davimacedo , thanks for your quick response and investigation.

I tried to set retryWrites=false, but unfortunately it didn't work for me.

I'll need to investigate more on my side before coming back to you with a test case or specific scenario.

Thanks again for your time

@fbeiger
Copy link
Author

fbeiger commented Sep 4, 2019

Hi again @davimacedo, quick update on this issue.

After detaching my mLab addon, then attach a fresh one (with the same config) and restoring the previous DB, this error finally came up:

MongoError: This MongoDB deployment does not support retryable writes. Please add retryWrites=false to your connection string.

Then obviously adding the query param (and #5983) solve it.

I don't know what caused the issue in the first place though.

Anyway, now everything is working fine, thanks!

@fbeiger fbeiger closed this as completed Sep 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants