[ 
https://issues.apache.org/jira/browse/COUCHDB-1289?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13158376#comment-13158376
 ] 

Filipe Manana commented on COUCHDB-1289:
----------------------------------------

Bob, just caught another case where the default TimeoutFun will be called 
(which stops the streaming immediately):


>From 7160021512161e3fa8f83165adc1a64285da6518 Mon Sep 17 00:00:00 2001
From: Filipe David Borba Manana <fdman...@apache.org>
Date: Mon, 28 Nov 2011 12:30:50 +0000
Subject: [PATCH 2/2] Make reset_heartbeat/0 a no-op

If no heartbeat option was given, the couch_changes heartbeat
function should really be a no-op, that is, to not set the
last_changes_heartbeat to the current time, otherwise the
default TimeoutFun (when no heartbeat option is given) might
be called which causes the changes feed to stop immediately
before folding the whole seq tree.
---
 src/couchdb/couch_changes.erl |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/src/couchdb/couch_changes.erl b/src/couchdb/couch_changes.erl
index f124567..72ee346 100644
--- a/src/couchdb/couch_changes.erl
+++ b/src/couchdb/couch_changes.erl
@@ -531,7 +531,12 @@ get_rest_db_updated(UserAcc) ->
     end.
 
 reset_heartbeat() ->
-    put(last_changes_heartbeat,now()).
+    case get(last_changes_heartbeat) of
+    undefined ->
+        ok;
+    _ ->
+        put(last_changes_heartbeat, now())
+    end.
 
 maybe_heartbeat(Timeout, TimeoutFun, Acc) ->
     Before = get(last_changes_heartbeat),
-- 
1.7.4.4

Do you agree?
                
> heartbeats skipped when continuous changes feed filter function produces no 
> results
> -----------------------------------------------------------------------------------
>
>                 Key: COUCHDB-1289
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-1289
>             Project: CouchDB
>          Issue Type: Bug
>          Components: Database Core
>            Reporter: Bob Dionne
>            Assignee: Bob Dionne
>            Priority: Minor
>              Labels: patch
>             Fix For: 1.2
>
>         Attachments: 0001-Ensure-heartbeats-are-not-skipped.patch, 
> 0002-Failing-etap-for-heartbeats-skipped.patch
>
>
> if the changes feed has a filter function that produces no results, 
> db_updated messages will still be sent and the heartbeat timeout will never 
> be reached.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to