diff options
author | Garren Smith <garren.smith@gmail.com> | 2018-08-07 13:46:24 +0200 |
---|---|---|
committer | Garren Smith <garren.smith@gmail.com> | 2018-08-07 13:46:24 +0200 |
commit | f3bee87064048dcbe9c89cf1da163b51d62073b5 (patch) | |
tree | 23d143356efb839447f1cff5b1539f2c9f97934c | |
parent | 9f56eb645e7f44ebfa379d34651cc830c084e68c (diff) | |
download | couchdb-mango-to-nodes.tar.gz |
fixes from reviewmango-to-nodes
-rw-r--r-- | src/mango/src/mango_cursor_view.erl | 26 | ||||
-rw-r--r-- | src/mango/test/20-no-timeout-test.py | 34 |
2 files changed, 32 insertions, 28 deletions
diff --git a/src/mango/src/mango_cursor_view.erl b/src/mango/src/mango_cursor_view.erl index 6a8f706e0..c41c23027 100644 --- a/src/mango/src/mango_cursor_view.erl +++ b/src/mango/src/mango_cursor_view.erl @@ -246,17 +246,7 @@ view_cb({row, Row}, #mrargs{extra = Options} = Acc) -> set_mango_msg_timestamp(); false -> put(mango_docs_examined, get(mango_docs_examined) + 1), - Current = erlang:system_time(millisecond), - LastPing = get(mango_last_msg_timestamp), - % Fabric will timeout if it has not heard a response from a worker node - % after 5 seconds. Send a ping every 4 seconds so the timeout doesn't happen. - case Current - LastPing > 4000 of - true -> - rexi:ping(), - set_mango_msg_timestamp(); - false -> - ok - end + maybe_send_mango_ping() end end, {ok, Acc}; @@ -268,6 +258,20 @@ view_cb(ok, ddoc_updated) -> rexi:reply({ok, ddoc_updated}). +maybe_send_mango_ping() -> + Current = erlang:system_time(millisecond), + LastPing = get(mango_last_msg_timestamp), + % Fabric will timeout if it has not heard a response from a worker node + % after 5 seconds. Send a ping every 4 seconds so the timeout doesn't happen. + case Current - LastPing > 4000 of + true -> + rexi:ping(), + set_mango_msg_timestamp(); + false -> + ok + end. + + set_mango_msg_timestamp() -> put(mango_last_msg_timestamp, erlang:system_time(millisecond)). diff --git a/src/mango/test/20-no-timeout-test.py b/src/mango/test/20-no-timeout-test.py index 978deb220..93dc146a3 100644 --- a/src/mango/test/20-no-timeout-test.py +++ b/src/mango/test/20-no-timeout-test.py @@ -16,23 +16,23 @@ import unittest class LongRunningMangoTest(mango.DbPerClass): - def setUp(self): - self.db.recreate() - docs = [] - for i in range(100000): - docs.append({ - "_id": str(i), - "another": "field" - }) - if i % 20000 == 0: - self.db.save_docs(docs) + def setUp(self): + self.db.recreate() docs = [] + for i in range(100000): + docs.append({ + "_id": str(i), + "another": "field" + }) + if i % 20000 == 0: + self.db.save_docs(docs) + docs = [] # This test should run to completion and not timeout - def test_query_does_not_time_out(self): - selector = { - "_id": {"$gt": 0}, - "another": "wrong" - } - docs = self.db.find(selector) - self.assertEqual(len(docs), 0) + def test_query_does_not_time_out(self): + selector = { + "_id": {"$gt": 0}, + "another": "wrong" + } + docs = self.db.find(selector) + self.assertEqual(len(docs), 0) |