[jira] [Commented] (COUCHDB-2631) Ensure that system databases callbacks are adds correctly for shared case
[ https://issues.apache.org/jira/browse/COUCHDB-2631?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15248545#comment-15248545 ] Nick Vatamaniuc commented on COUCHDB-2631: -- {code} IsReplicatorDb = DbName == config:get("replicator", "db", "_replicator") {code} Doesn't apply to 2.x anymore. Local replicator is always "_replicator". Also it expects binaries. {code} (node1@127.0.0.1)4> couch_db:normalize_dbname("shards/-1fff/_users.1460972107"). "shards/-1fff/_users.1460972107" (node1@127.0.0.1)5> couch_db:normalize_dbname("shards/-1fff/_users"). "shards/-1fff/_users" (node1@127.0.0.1)6> couch_db:normalize_dbname(<<"shards/-1fff/_users">>). <<"_users">> (node1@127.0.0.1)7> couch_db:normalize_dbname(<<"shards/-1fff/_users.134565677">>). <<"_users">> {code} [~eiri] pointed to this PR that should handle this issue https://github.com/apache/couchdb-couch/pull/160 > 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 > Components: BigCouch >Reporter: Alexander Shorin >Priority: Blocker > Labels: needs-pr > Fix For: 2.0.0 > > > 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/-1fff/_users.1424979962" -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (COUCHDB-2631) Ensure that system databases callbacks are adds correctly for shared case
[ https://issues.apache.org/jira/browse/COUCHDB-2631?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15248454#comment-15248454 ] Jan Lehnardt commented on COUCHDB-2631: --- …which is used in: path_ends_with(Path, Suffix) -> Suffix == couch_db:normalize_dbname(Path). > 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 > Components: BigCouch >Reporter: Alexander Shorin >Priority: Blocker > Labels: needs-pr > Fix For: 2.0.0 > > > 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/-1fff/_users.1424979962" -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (COUCHDB-2631) Ensure that system databases callbacks are adds correctly for shared case
[ https://issues.apache.org/jira/browse/COUCHDB-2631?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15248452#comment-15248452 ] Jan Lehnardt commented on COUCHDB-2631: --- I don’t know how to validate whether this works as intended or not, but I see this, when I log things before the if with this: io:format("~nDbName: ~p, IsUsersDb: ~p, IsReplicatorDb: ~p", [DbName, IsUsersDb, IsReplicatorDb]), DbName: "shards/-1fff/_replicator.1460972107", IsUsersDb: false, IsReplicatorDb: false DbName: "shards/-1fff/_users.1460972107", IsUsersDb: false, IsReplicatorDb: false DbName: "_users", IsUsersDb: true, IsReplicatorDb: false DbName: "_replicator", IsUsersDb: false, IsReplicatorDb: false (!) especially the last one doesn’t look right ;) Maybe because this doesn’t account for the DbName not a binary? couch_db:normalize_dbname(<<"shards/", _/binary>> = Path) -> lists:last(binary:split(mem3:dbname(Path), <<"/">>, [global])); normalize_dbname(DbName) -> DbName. > 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 > Components: BigCouch >Reporter: Alexander Shorin >Priority: Blocker > Labels: needs-pr > Fix For: 2.0.0 > > > 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/-1fff/_users.1424979962" -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (COUCHDB-2631) Ensure that system databases callbacks are adds correctly for shared case
[ https://issues.apache.org/jira/browse/COUCHDB-2631?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15244821#comment-15244821 ] Jan Lehnardt commented on COUCHDB-2631: --- Comment by rnewson via IRC: <+rnewson> I'm surprised by, but I'm going to verify locally, I think we send the right name in here <+rnewson> if not , it's simple to call mem3:dbname(DbName) to get the 'proper' name that would make that logic work > 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 > Components: BigCouch >Reporter: Alexander Shorin >Priority: Blocker > Labels: needs-pr > Fix For: 2.0.0 > > > 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/-1fff/_users.1424979962" -- This message was sent by Atlassian JIRA (v6.3.4#6332)