[
https://issues.apache.org/jira/browse/COUCHDB-709?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12849558#action_12849558
]
Chris Anderson commented on COUCHDB-709:
----------------------------------------
ok, Jira seems unable to accept my patch upload. Follows in plaintext.
diff --git a/share/www/script/couch_tests.js b/share/www/script/couch_tests.js
index 85d0706..3978d48 100644
--- a/share/www/script/couch_tests.js
+++ b/share/www/script/couch_tests.js
@@ -149,6 +149,25 @@ function stringFun(fun) {
return string;
}
+function waitForRestart() {
+ var waiting = true;
+ while (waiting) {
+ try {
+ CouchDB.request("GET", "/");
+ CouchDB.request("GET", "/");
+ waiting = false;
+ } catch(e) {
+ // the request will fail until restart completes
+ }
+ }
+};
+
function restartServer() {
- CouchDB.request("POST", "/_restart");
+ var xhr;
+ try {
+ CouchDB.request("POST", "/_restart");
+ } catch(e) {
+ // this request may sometimes fail
+ }
+ waitForRestart();
}
diff --git a/share/www/script/test/reader_acl.js
b/share/www/script/test/reader_acl.js
index d173d70..a3b6bd8 100644
--- a/share/www/script/test/reader_acl.js
+++ b/share/www/script/test/reader_acl.js
@@ -28,6 +28,7 @@ couchTests.reader_acl = function(debug) {
roles : ["top-secret"]
}, "funnybone");
T(usersDb.save(jchrisUserDoc).ok);
+ usersDb.ensureFullCommit();
T(CouchDB.session().userCtx.name == null);
@@ -41,12 +42,15 @@ couchTests.reader_acl = function(debug) {
names : ["joe","barb"]
}
}).ok);
-
- usersDb.ensureFullCommit();
- // security changes will always commit synchronously
- restartServer();
-
- // can't read it as jchris
+ } finally {
+ CouchDB.logout();
+ }
+ }
+
+ // split into 2 funs so we can test restart behavior
+ function testFun2() {
+ try {
+ // can't read it as jchris b/c he's missing the needed role
T(CouchDB.login("[email protected]", "funnybone").ok);
T(CouchDB.session().userCtx.name == "[email protected]");
@@ -151,7 +155,7 @@ couchTests.reader_acl = function(debug) {
} finally {
CouchDB.logout();
}
- }
+ };
run_on_modified_server(
[{section: "httpd",
@@ -161,4 +165,16 @@ couchTests.reader_acl = function(debug) {
key: "authentication_db", value: "test_suite_users"}],
testFun
);
+
+ // security changes will always commit synchronously
+ restartServer();
+
+ run_on_modified_server(
+ [{section: "httpd",
+ key: "authentication_handlers",
+ value: "{couch_httpd_auth, cookie_authentication_handler},
{couch_httpd_auth, default_authentication_handler}"},
+ {section: "couch_httpd_auth",
+ key: "authentication_db", value: "test_suite_users"}],
+ testFun2
+ );
}
diff --git a/src/couchdb/couch_server_sup.erl b/src/couchdb/couch_server_sup.erl
index d89e987..da0fbdb 100644
--- a/src/couchdb/couch_server_sup.erl
+++ b/src/couchdb/couch_server_sup.erl
@@ -32,12 +32,7 @@ start_link(IniFiles) ->
end.
restart_core_server() ->
- supervisor:terminate_child(couch_primary_services, couch_server),
- supervisor:terminate_child(couch_secondary_services, stats_aggregator),
- supervisor:terminate_child(couch_secondary_services, stats_collector),
- supervisor:restart_child(couch_primary_services, couch_server),
- supervisor:restart_child(couch_secondary_services, stats_collector),
- supervisor:restart_child(couch_secondary_services, stats_aggregator).
+ init:restart().
couch_config_start_link_wrapper(IniFiles, FirstConfigPid) ->
case is_process_alive(FirstConfigPid) of
> Restart actually restarts the server
> ------------------------------------
>
> Key: COUCHDB-709
> URL: https://issues.apache.org/jira/browse/COUCHDB-709
> Project: CouchDB
> Issue Type: Improvement
> Components: Database Core
> Reporter: Chris Anderson
>
> This patch will cause CouchDB to actually restart the server when a POST is
> made to /_restart
> The old way was unreliable as supervisors would shut things down
> asynchronously. This new way is much more brute force, which makes it more
> deterministic.
> This only really effects the test suite. I'm only pushing the patch through
> Jira to see if people see room for improvements.
> One improvement would be to add a timestamp for server boot time to the /
> response, but I seem to have avoided the need for that with my double GET
> magic.
> Do note: restart now drops any temporary config, hence the change to the
> reader_acls test.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.