Couchdb: While using main branch /_reshard/jobs split always returns with 400 or 500 error

Created on 1 Mar 2021  路  3Comments  路  Source: apache/couchdb

Description

The POST /_reshard/jobs endpoint is not working with any existing db name while I was using the main branch.

curl --location --request POST 'http://127.0.0.1:15984/_reshard/jobs' \
--header 'Content-Type: application/json' \
--data-raw '{
    "db": "_users",
    "type": "split"
}'

Results with a 400 error however the _users db is existing:

{
    "error": "bad_request",
    "reason": "Invalid `db`"
}

I tried this out with other existing db names as well, but those are not working as well.

An odd thing is when I try out the endpoint with the _dbs value:

curl --location --request POST 'http://127.0.0.1:15984/_reshard/jobs' \
--header 'Content-Type: application/json' \
--data-raw '{
    "db": "_dbs",
    "type": "split"
}'

It results an 500 error:

[
    {
        "error": "{'EXIT',\n    {function_clause,\n        [{mem3_reshard,shard_from_name,\n             [<<\"_dbs\">>],\n             [{file,\"src/mem3_reshard.erl\"},{line,199}]},\n         {mem3_reshard,start_split_job,1,\n             [{file,\"src/mem3_reshard.erl\"},{line,93}]},\n         {rpc,local_call,3,[{file,\"rpc.erl\"},{line,321}]},\n         {mem3_reshard_api,'-create_jobs/5-fun-0-',1,\n             [{file,\"src/mem3_reshard_api.erl\"},{line,32}]},\n         {lists,map,2,[{file,\"lists.erl\"},{line,1239}]},\n         {mem3_reshard_httpd,handle_reshard_req,1,\n             [{file,\"src/mem3_reshard_httpd.erl\"},{line,108}]},\n         {chttpd,handle_req_after_auth,2,[{file,\"src/chttpd.erl\"},{line,330}]},\n         {chttpd,process_request,1,[{file,\"src/chttpd.erl\"},{line,311}]}]}}",
        "node": "[email protected]",
        "shard": "_dbs"
    }
]

Steps to Reproduce

Expected Behaviour

  1. A 201 or a 202 response, like this:
[
    {
        "ok": true,
        "id": "001-46df42bb53df24c7d32212982479c85e7f4b5bdfe04526b47a0e3000899af438",
        "node": "nonode@nohost",
        "shard": "shards/00000000-7fffffff/_global_changes.1614539418"
    },
    {
        "ok": true,
        "id": "001-8964009e85822a354ac67412d003f5aa05d5c5adf9f37b70f5453e859250b6fa",
        "node": "nonode@nohost",
        "shard": "shards/80000000-ffffffff/_global_changes.1614539418"
    }
]
  1. Or an error response with a reason that explains the cause of the problem more.

Your Environment

  • CouchDB version used: a9e0ebe2434e4bcdc7fe156e888767e7e57c26e
  • Browser name and version: cURL
  • Operating system and version: BigSur 11.2.1

Additional Context

not a bug

All 3 comments

You probably want the 3.x branch, not main, which doesn't have the 2.x/3.x concept of shards anymore.

Thanks for the information, @wohali!

If main does not have the concept of shards anymore, could the response code be a 403 or a 410 then? I think the 400 error message (Invalid `db`) is misleading here.

It also came to my notice that some of the GET reshard endpoints are working while I was running the main branch, so I would like to ask for similar response codes there if you reach the point where you turn off the reshard endpoints properly. Thanks in front!

main is under heavy development towards 4.0 and is not feature complete, as far as I understand.

I would not be using it at the moment and would stick with 3.x for any production use.

I'm sure a pass will be done to clean up the removed endpoints for 4.0.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

JohnOllhorn picture JohnOllhorn  路  5Comments

wohali picture wohali  路  5Comments

popojargo picture popojargo  路  5Comments

maciozo picture maciozo  路  5Comments

stheobald picture stheobald  路  4Comments