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

convert erlfdb_error 2101 to transaction_too_large for main #3222

Merged
merged 1 commit into from
Oct 21, 2020

Conversation

jiangphcn
Copy link
Contributor

@jiangphcn jiangphcn commented Oct 21, 2020

Overview

If transaction exceeds byte limit using the _bulk_docs endpoint, the {u'reason': u'2101', u'ref': 3853288219, u'error': u'erlfdb_error'} with 500 error code was returned. This is user-friendly. Using this PR is to provide meaningful error message to users.

Testing recommendations

The test python code:

import requests, json, random, string, os
print(requests.post(
    "https://127.0.0.1:15984/foo/_bulk_docs"
    , json={
        "docs":
            [
                {"foo": "".join(random.choice(string.ascii_lowercase) for x in range(16000000))}
            ]}
    , auth=('foo', 'bar')
).json())

Original response:

{u'reason': u'2101', u'ref': 3853288219, u'error': u'erlfdb_error'}

New response:

{u'reason': u'The request transaction is larger than 10MB', u'error': u'transaction_too_large'}

make elixir tests=test/elixir/test/bulk_docs_test.exs
make exunit tests=src/couchdb/test/elixir/test/bulk_docs_test.exs

BulkDocsTest
  * test bulk docs raises error for invlaid `docs` parameter (75.5ms)
  * test bulk docs supplies `id` if not provided in doc (38.9ms)
  * test bulk docs can detect conflicts (64.4ms)
  * test bulk docs raises error for invlaid `new_edits` parameter (13.3ms)
  * test bulk docs raises error for missing `docs` parameter (13.0ms)
  * test bulk docs raises transaction_too_large error for transaction larger than 10MB (1384.9ms)
  * test bulk docs raises error for `all_or_nothing` option (13.6ms)
  * test bulk docs raises conflict error for combined update & delete (40.6ms)
  * test bulk docs emits conflict error for duplicate doc `_id`s (23.2ms)
  * test bulk docs can create, update, & delete many docs per request (78.3ms)


Finished in 2.0 seconds
10 tests, 0 failures

Randomized with seed 913112

Related Issues or Pull Requests

#3215

Checklist

@jiangphcn
Copy link
Contributor Author

talked to @nickva before. He agrees that we can use +1 in #3215 (review) to merge this PR.

@jiangphcn jiangphcn merged commit ab70b75 into main Oct 21, 2020
@jiangphcn jiangphcn deleted the transaction_too_large-main branch October 21, 2020 03:15
Copy link
Contributor

@nickva nickva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Added just for completeness

@jiangphcn
Copy link
Contributor Author

thanks @nickva

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

Successfully merging this pull request may close these issues.

2 participants