[
https://issues.apache.org/jira/browse/COUCHDB-2422?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14192113#comment-14192113
]
Mike Wallace commented on COUCHDB-2422:
---------------------------------------
For the cassim-specific issue we could side-step the issue by having
cassim_metadata_cache:security_meta_id/1 [1] add a prefix to the doc id.
For the shard map issue I can think of two options:
1. Special-casing updates to the dbs database made via the HTTP admin port.
This could be done by having couch_httpd_db.erl pass the Db name through to a
new couch_doc:validate_docid/2 function (e.g. at [2] and [3]).
2. Decoupling the database name from the shard map id by adding something
similar to cassim_metadata_cache:security_meta_id/1 to mem3_util and having it
add a prefix to the database name instead of just using the database name
directly [4]. This would require edits in a number of places and quite possibly
break things elsewhere in the system. We could do it conditionally just for the
special databases though I'm not sure that'd help.
I'm not particularly enamoured with either of these options. What do other folk
think?
Also noting that we could do option 1 for the cassim issue though given cassim
is a user-facing database on the 5984 port and the security metadata DB can be
renamed I'm not sure that's a good plan - people would be able to set a DB as
their security metadata, create a bunch of docs with reserved IDs, then change
the security metadata DB to something else and end up with documents they can't
edit.
[1]
https://github.com/apache/couchdb-cassim/blob/master/src/cassim_metadata_cache.erl#L71-L73
[2]
https://github.com/apache/couchdb-couch/blob/master/src/couch_httpd_db.erl#L537
[3]
https://github.com/apache/couchdb-couch/blob/master/src/couch_httpd_db.erl#L571
[4] https://github.com/cloudant/mem3/blob/master/src/mem3_util.erl#L82
> Cassim and underscored databases
> --------------------------------
>
> Key: COUCHDB-2422
> URL: https://issues.apache.org/jira/browse/COUCHDB-2422
> Project: CouchDB
> Issue Type: Bug
> Security Level: public(Regular issues)
> Components: Database Core
> Reporter: Alexander Shorin
>
> 1. Run dev cluster
> 2. Create {{_users}} database
> {code}
> http PUT http://localhost:15984/_users
> HTTP/1.1 201 Created
> Cache-Control: must-revalidate
> Content-Length: 12
> Content-Type: text/plain; charset=utf-8
> Date: Fri, 31 Oct 2014 10:36:19 GMT
> Location: http://localhost:15984/_users
> Server: CouchDB/9938fac (Erlang OTP/17)
> X-Couch-Request-ID: f273be89
> X-CouchDB-Body-Time: 0
> {"ok":true}
> {code}
> 3. Create cassim database
> {code}
> http PUT http://localhost:15984/cassim
> HTTP/1.1 201 Created
> Cache-Control: must-revalidate
> Content-Length: 12
> Content-Type: text/plain; charset=utf-8
> Date: Fri, 31 Oct 2014 10:37:06 GMT
> Location: http://localhost:15984/cassim
> Server: CouchDB/9938fac (Erlang OTP/17)
> X-Couch-Request-ID: 8bdcc974
> X-CouchDB-Body-Time: 0
> {"ok":true}
> {code}
> 4. Try to access {{_users}} database:
> {code}
> http http://localhost:15984/_users
> HTTP/1.1 400 Bad Request
> Cache-Control: must-revalidate
> Content-Length: 89
> Content-Type: text/plain; charset=utf-8
> Date: Fri, 31 Oct 2014 10:34:22 GMT
> Server: CouchDB/9938fac (Erlang OTP/17)
> X-Couch-Request-ID: e9f4a5b3
> X-CouchDB-Body-Time: 0
> {"error":"bad_request","reason":"Only reserved document ids may start with
> underscore."}
> {code}
> Oh wait...? This is because cassim creates documents with database name as
> the prefix and for {{_users}} and {{_replicator}} it clashes with
> restrictions about document names.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)