Hi,

Here's a patch that release the stream_busyobj from the sess in cnt_error.
So if the object is currently fetched (and streamed) for another client, varnish will properly deliver the error and varnish wont die.

It happened to me when we did a PURGE request on a object that was fetched at the same time.
Using the following vcl:

sub vcl_fetch {
    set beresp.do_stream = true;
}

sub vcl_hit {
        if (req.request == "PURGE") {
                purge;
                error 200 "Purged.";
        }
}
-----
Varnish died:
Child (1290) died signal=6
Child (1290) Panic message: Assert error in RES_StreamWrite(), cache_response.c line 444:
  Condition(stlen <= st->len) not true.
...

Full trace here: http://pastebin.com/DaqDZ9U6


I hope it's the right way to fix it,

Cheers,

--
Jocelyn De La Rosa - Developer, Research&  Engineering
SmartJog | www.smartjog.com
27 Blvd Hippolyte Marquès, 94200 Ivry-sur-Seine, France

>From af80beed3f52a8d1c9f5b48f2bff2d3e1c6c0613 Mon Sep 17 00:00:00 2001
From: Jocelyn De La Rosa <[email protected]>
Date: Thu, 3 May 2012 13:54:29 +0200
Subject: [PATCH] Release the stream_busyobj if we go to error while another thread is streaming

---
 bin/varnishd/cache_center.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/bin/varnishd/cache_center.c b/bin/varnishd/cache_center.c
index 45da018..396d3c5 100644
--- a/bin/varnishd/cache_center.c
+++ b/bin/varnishd/cache_center.c
@@ -515,6 +515,15 @@ cnt_error(struct sess *sp)
 	sp->doclose = "error";
 	sp->wantbody = 1;
 
+	/* If the object was streamed, we don't want to hold the busyobj */
+	if (sp->stream_busyobj) {
+		Lck_Lock(&sp->stream_busyobj->mtx);
+		sp->stream_busyobj->stream_refcnt--;
+		Lck_Unlock(&sp->stream_busyobj->mtx);
+		sp->stream_busyobj = NULL;
+	}
+	assert(sp->stream_busyobj == NULL);
+
 	assert(sp->handling == VCL_RET_DELIVER);
 	sp->err_code = 0;
 	sp->err_reason = NULL;
-- 
1.7.2.5

_______________________________________________
varnish-dev mailing list
[email protected]
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-dev

Reply via email to