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

chewbranca pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/couchdb.git


The following commit(s) were added to refs/heads/main by this push:
     new fae8761c1 Flush chttpd_db monitor refs on demonitor (#4906)
fae8761c1 is described below

commit fae8761c1ee7c5919a22274fd9356a45e9271316
Author: Russell Branca <[email protected]>
AuthorDate: Tue Dec 12 14:11:39 2023 -0800

    Flush chttpd_db monitor refs on demonitor (#4906)
    
    This ensures that the coordinator process flushes on demonitoring of the
    attachment refs in chttpd_db. The problem here is that it's possible to
    receive a 'DOWN' message for the monitor ref that is not receive'ed,
    causing it to stick around in the coordinator message queue while the
    next http request is handled. The pending message will not become
    apparent until the next fabric call is invoked, as fabric expects to
    have full access to all messages in the calling process, an expectation
    which is violated by the pending message and causes a case clause crash
    in the fabric receive message callbacks.
    
    I noticed this during eunit runs with stubbed attachment handles that
    generate an immediate noproc message on the monitor call. Normal
    operations should not result in an immediate noproc result on monitoring
    the attachment process, however, any failure that causes the attachment
    process to fail between acquisition of the refs and the demonitor calls
    will induce this bug, causing the next http request handled by the
    particular chttpd coordinator pool processs to fail on whatever next
    fabric call is made.
---
 src/chttpd/src/chttpd_db.erl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/chttpd/src/chttpd_db.erl b/src/chttpd/src/chttpd_db.erl
index 9b1aff54f..8cc7a8619 100644
--- a/src/chttpd/src/chttpd_db.erl
+++ b/src/chttpd/src/chttpd_db.erl
@@ -2248,7 +2248,7 @@ monitor_attachments(Att) ->
     monitor_attachments([Att]).
 
 demonitor_refs(Refs) when is_list(Refs) ->
-    [demonitor(Ref) || Ref <- Refs].
+    [demonitor(Ref, [flush]) || Ref <- Refs].
 
 % Return attachments which are not stubs
 non_stubbed_attachments(Atts) when is_list(Atts) ->

Reply via email to