You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2020/01/06 22:12:07 UTC

[couchdb] branch sm-60-make-oom-errors-fatal updated (6ab52f5 -> 0813d59)

This is an automated email from the ASF dual-hosted git repository.

davisp pushed a change to branch sm-60-make-oom-errors-fatal
in repository https://gitbox.apache.org/repos/asf/couchdb.git.


 discard 6ab52f5  Match the OOM beahvior of 1.8.5
    omit 3bbe00b  Set `couchTests.elixir = true` to skip ported tests
    omit 641870d  Fix JS tests on SpiderMonkey 60
     new c74c851  Set `couchTests.elixir = true` to skip ported tests
     new 6d5608e  Fix view timeout error test
     new 0813d59  Match the OOM beahvior of 1.8.5

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (6ab52f5)
            \
             N -- N -- N   refs/heads/sm-60-make-oom-errors-fatal (0813d59)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 share/server/state.js                   | 1 -
 share/server/views.js                   | 4 ----
 src/couch/test/eunit/couch_js_tests.erl | 4 ++--
 3 files changed, 2 insertions(+), 7 deletions(-)


[couchdb] 01/03: Set `couchTests.elixir = true` to skip ported tests

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davisp pushed a commit to branch sm-60-make-oom-errors-fatal
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit c74c851535df8de31464307c35365ce3582e0abd
Author: Paul J. Davis <pa...@gmail.com>
AuthorDate: Mon Jan 6 11:47:43 2020 -0600

    Set `couchTests.elixir = true` to skip ported tests
    
    This avoids the 1.2s pause between tests to save time during the test
    suite. All ported tests are also logged to measure our progress porting
    the JS test suite.
---
 test/javascript/tests/auth_cache.js  | 2 +-
 test/javascript/tests/cookie_auth.js | 2 +-
 test/javascript/tests/users_db.js    | 2 +-
 test/javascript/tests/utf8.js        | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/test/javascript/tests/auth_cache.js b/test/javascript/tests/auth_cache.js
index ca8f077..73fec35 100644
--- a/test/javascript/tests/auth_cache.js
+++ b/test/javascript/tests/auth_cache.js
@@ -10,8 +10,8 @@
 // License for the specific language governing permissions and limitations under
 // the License.
 
+couchTests.elixir = true;
 couchTests.auth_cache = function(debug) {
-  return console.log('done in test/elixir/test/auth_cache_test.exs');
   if (debug) debugger;
 
   // Simple secret key generator
diff --git a/test/javascript/tests/cookie_auth.js b/test/javascript/tests/cookie_auth.js
index 0dce6bd..2d49ebe 100644
--- a/test/javascript/tests/cookie_auth.js
+++ b/test/javascript/tests/cookie_auth.js
@@ -10,9 +10,9 @@
 // License for the specific language governing permissions and limitations under
 // the License.
 
+couchTests.elixir = true;
 couchTests.cookie_auth = function(debug) {
   // This tests cookie-based authentication.
-  return console.log('done in test/elixir/test/cookie_auth_test.exs');
 
   var db_name = get_random_db_name();
   var db = new CouchDB(db_name, {"X-Couch-Full-Commit":"false"});
diff --git a/test/javascript/tests/users_db.js b/test/javascript/tests/users_db.js
index b13adff..3ce8025 100644
--- a/test/javascript/tests/users_db.js
+++ b/test/javascript/tests/users_db.js
@@ -10,8 +10,8 @@
 // License for the specific language governing permissions and limitations under
 // the License.
 
+couchTests.elixir = true;
 couchTests.users_db = function(debug) {
-  return console.log('done in test/elixir/test/users_db_test.exs');
 
   // This tests the users db, especially validations
   // this should also test that you can log into the couch
diff --git a/test/javascript/tests/utf8.js b/test/javascript/tests/utf8.js
index a1092c1..cee4d30 100644
--- a/test/javascript/tests/utf8.js
+++ b/test/javascript/tests/utf8.js
@@ -10,8 +10,8 @@
 // License for the specific language governing permissions and limitations under
 // the License.
 
+couchTests.elixir = true;
 couchTests.utf8 = function(debug) {
-  return console.log('done in test/elixir/test/utf8_test.exs');
   var db_name = get_random_db_name();
   var db = new CouchDB(db_name, {"X-Couch-Full-Commit":"false"});
   db.createDb();


[couchdb] 02/03: Fix view timeout error test

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davisp pushed a commit to branch sm-60-make-oom-errors-fatal
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 6d5608e1e93644a5a7bd5119b7d8b64d6cb6acf9
Author: Paul J. Davis <pa...@gmail.com>
AuthorDate: Mon Jan 6 16:09:30 2020 -0600

    Fix view timeout error test
    
    Newer SpiderMonkey versions are fast enough that this can OOM before the
    timeout occurs. To avoid the issue we just avoid generating garbage on
    the heap.
---
 test/javascript/tests/view_errors.js | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/test/javascript/tests/view_errors.js b/test/javascript/tests/view_errors.js
index 7577b80..43db3c8 100644
--- a/test/javascript/tests/view_errors.js
+++ b/test/javascript/tests/view_errors.js
@@ -145,7 +145,7 @@ couchTests.view_errors = function(debug) {
         _id:"_design/infinite",
         language: "javascript",
         views: {
-          "infinite_loop" :{map:"function(doc) {while(true){emit(doc,doc);}};"}
+          "infinite_loop" :{map:"function(doc) {while(true){};}"}
         }
       };
       T(db.save(designDoc3).ok);
@@ -154,7 +154,7 @@ couchTests.view_errors = function(debug) {
           db.view("infinite/infinite_loop");
           T(0 == 1);
       } catch(e) {
-          T(e.error == "os_process_error" || e.error == "unnamed_error");
+          T(e.error == "os_process_error");
       }
 
       // Check error responses for invalid multi-get bodies.


[couchdb] 03/03: Match the OOM beahvior of 1.8.5

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davisp pushed a commit to branch sm-60-make-oom-errors-fatal
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 0813d599a5725aef10ee2e9d29f66f293f2b38f5
Author: Paul J. Davis <pa...@gmail.com>
AuthorDate: Mon Jan 6 11:06:40 2020 -0600

    Match the OOM beahvior of 1.8.5
    
    Apparently SpiderMonkey 60 changed the behavior of OOM errors to not
    exit the VM. This updates the SpiderMonkey 60 implementation to match
    that behavior.
---
 src/couch/priv/couch_js/60/main.cpp     |  1 +
 src/couch/priv/couch_js/60/util.cpp     |  8 ++++++
 src/couch/priv/couch_js/60/util.h       |  1 +
 src/couch/test/eunit/couch_js_tests.erl | 45 +++++++++++++++++++++++++++++++++
 4 files changed, 55 insertions(+)

diff --git a/src/couch/priv/couch_js/60/main.cpp b/src/couch/priv/couch_js/60/main.cpp
index ecedfbd..e36bc61 100644
--- a/src/couch/priv/couch_js/60/main.cpp
+++ b/src/couch/priv/couch_js/60/main.cpp
@@ -420,6 +420,7 @@ main(int argc, const char* argv[])
         return 1;
 
     JS::SetWarningReporter(cx, couch_error);
+    JS::SetOutOfMemoryCallback(cx, couch_oom, NULL);
     JS_SetContextPrivate(cx, args);
     JS_SetSecurityCallbacks(cx, &security_callbacks);
 
diff --git a/src/couch/priv/couch_js/60/util.cpp b/src/couch/priv/couch_js/60/util.cpp
index 894b425..92c6cbf 100644
--- a/src/couch/priv/couch_js/60/util.cpp
+++ b/src/couch/priv/couch_js/60/util.cpp
@@ -309,6 +309,14 @@ couch_error(JSContext* cx, JSErrorReport* report)
 }
 
 
+void
+couch_oom(JSContext* cx, void* data)
+{
+    fprintf(stderr, "out of memory\n");
+    exit(1);
+}
+
+
 bool
 couch_load_funcs(JSContext* cx, JS::HandleObject obj, JSFunctionSpec* funcs)
 {
diff --git a/src/couch/priv/couch_js/60/util.h b/src/couch/priv/couch_js/60/util.h
index 45caa34..407e3e6 100644
--- a/src/couch/priv/couch_js/60/util.h
+++ b/src/couch/priv/couch_js/60/util.h
@@ -35,6 +35,7 @@ JSString* couch_readline(JSContext* cx, FILE* fp);
 size_t couch_readfile(const char* file, char** outbuf_p);
 void couch_print(JSContext* cx, unsigned int argc, JS::CallArgs argv);
 void couch_error(JSContext* cx, JSErrorReport* report);
+void couch_oom(JSContext* cx, void* data);
 bool couch_load_funcs(JSContext* cx, JS::HandleObject obj, JSFunctionSpec* funcs);
 
 
diff --git a/src/couch/test/eunit/couch_js_tests.erl b/src/couch/test/eunit/couch_js_tests.erl
new file mode 100644
index 0000000..d3d92a2
--- /dev/null
+++ b/src/couch/test/eunit/couch_js_tests.erl
@@ -0,0 +1,45 @@
+% Licensed under the Apache License, Version 2.0 (the "License"); you may not
+% use this file except in compliance with the License. You may obtain a copy of
+% the License at
+%
+%   http://www.apache.org/licenses/LICENSE-2.0
+%
+% Unless required by applicable law or agreed to in writing, software
+% distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+% WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+% License for the specific language governing permissions and limitations under
+% the License.
+
+-module(couch_js_tests).
+-include_lib("eunit/include/eunit.hrl").
+
+
+-define(FUNC, <<
+  "function(doc) {\n"
+  "  var val = \"0123456789ABCDEF\";\n"
+  "  while(true) {emit(val, val);}\n"
+  "}\n"
+>>).
+
+
+couch_js_test_() ->
+    {
+        "Test couchjs",
+        {
+            setup,
+            fun test_util:start_couch/0,
+            fun test_util:stop_couch/1,
+            [
+                fun should_exit_on_oom/0
+            ]
+        }
+    }.
+
+
+should_exit_on_oom() ->
+    Proc = couch_query_servers:get_os_process(<<"javascript">>),
+    true = couch_query_servers:proc_prompt(Proc, [<<"add_fun">>, ?FUNC]),
+    ?assertThrow(
+            {os_process_error, {exit_status, 1}},
+            couch_query_servers:proc_prompt(Proc, [<<"map_doc">>, <<"{}">>])
+        ).