Alexander Shorin created COUCHDB-2631:
-----------------------------------------

             Summary: Ensure that system databases callbacks are adds correctly 
for shared case
                 Key: COUCHDB-2631
                 URL: https://issues.apache.org/jira/browse/COUCHDB-2631
             Project: CouchDB
          Issue Type: Bug
      Security Level: public (Regular issues)
          Components: BigCouch
            Reporter: Alexander Shorin


We have the following code in 
[couch_server|https://github.com/apache/couchdb-couch/blob/master/src/couch_server.erl#L119-L143]

{code}
maybe_add_sys_db_callbacks(DbName, Options) when is_binary(DbName) ->
    maybe_add_sys_db_callbacks(?b2l(DbName), Options);
maybe_add_sys_db_callbacks(DbName, Options) ->
    DbsDbName = config:get("mem3", "shard_db", "dbs"),
    NodesDbName = config:get("mem3", "node_db", "nodes"),
    IsReplicatorDb = DbName == config:get("replicator", "db", "_replicator") 
orelse
        path_ends_with(DbName, <<"_replicator">>),
    IsUsersDb = DbName ==config:get("couch_httpd_auth", "authentication_db", 
"_users") orelse
        path_ends_with(DbName, <<"_users">>),
    if
        DbName == DbsDbName ->
            [sys_db | Options];
        DbName == NodesDbName ->
            [sys_db | Options];
        IsReplicatorDb ->
            [{before_doc_update, fun 
couch_replicator_manager:before_doc_update/2},
             {after_doc_read, fun couch_replicator_manager:after_doc_read/2},
             sys_db | Options];
        IsUsersDb ->
            [{before_doc_update, fun couch_users_db:before_doc_update/2},
             {after_doc_read, fun couch_users_db:after_doc_read/2},
             sys_db | Options];
        true ->
            Options
    end.
{code}

Which works perfectly except if system database is clustered. So, for shared 
_users and _replicator the check condition will not work since shared databases 
ends with timestamp and full name looks as 
"shards/00000000-1fffffff/_users.1424979962"



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to