shutdown-and-flushing: Improve shutdown, support/test FlushHtml #936
Conversation
14460b2
to
768ccc5
Compare
Tests that ran today brought a problem to light. I'll look into that, and make a comment here when I've pushed the fix. |
This looks rather dangerous to me --- the code in ProxyFetch doesn't expect Done to be called externally like this, and it looks like a way towards crashes accessing freed memory, as fetch code may end up still writing towards the fetch object. |
@morlovich thanks for having a look. We call [1] https://github.com/pagespeed/ngx_pagespeed/blob/master/src/ngx_pagespeed.cc#L1696 |
Does something ensure that you don't call any further Write() and Done() On Tue, Mar 17, 2015 at 10:19 AM, Otto van der Schaaf <
|
@morlovich Yes, nps won't touch any proxy fetches after calling Done(true|false) on them. |
Might you not still have an html parse ongoing, though? On Tue, Mar 17, 2015 at 11:06 AM, Otto van der Schaaf <
|
@morlovich Yes, it is possible there are html parses going on indeed. Does calling proxy_fetch->Done(false) not stop/cancel the associated html parser? The code that uses this call is at: This works if we are lucky, but no guarantees. With some synthetic ongoing load this still crashes. |
Hmm... You're right, it should behave correctly as long as there are no Sorry for misleading you. On Tue, Mar 17, 2015 at 3:28 PM, Otto van der Schaaf <
|
@morlovich I'm not sure, but would it be a reasonable idea to add a separate call to the driver factory to stop the schedulers as a first step in shutting down quickly? |
fe2ddf7
to
e1c9b3d
Compare
@morlovich Running without valgrind, quick shutdowns seems stable after some tweaking. However, I sometimes see sequences like this leading up to a
Is this With this patch, the quick shutdown looks like this:
@jeffkaufman |
Patching nginx to let us finish cleaning up under high load with valgrind sounds like the right way to handle it for me. Ideally the patch would make shutdown timeout a configuration option, so we could turn it off without rebuiding nginx, but if that's too annoying I can make our scripts just patch the nginx code before running valgrind and handle the rebuild. If you do make it a configuration option I wonder whether they would accept that upstream? |
d0af3fe
to
2d112a4
Compare
@morlovich never mind the question about |
8f597a8
to
2dcaf7b
Compare
c9ed1a0
to
9eda614
Compare
Is this ready for final review or are you still working on it? ngx_pagespeed developers would need to patch in your nginx change, right? When this does go in, can you add that to https://github.com/pagespeed/ngx_pagespeed/wiki/Testing ? |
@jeffkaufman This is ready for review, and I'll make the wiki change once this goes in! |
@@ -193,7 +234,8 @@ ngx_int_t NgxBaseFetch::CopyBufferToNginx(ngx_chain_t** link_ptr) { | |||
} | |||
|
|||
int rc = string_piece_to_buffer_chain( | |||
request_->pool, buffer_, link_ptr, done_called_ /* send_last_buf */); | |||
request_->pool, buffer_, link_ptr, done_called_ /* send_last_buf */, | |||
true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: comment what this "true" means
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done (true
indicates buf->flush
will be set)
LGTM |
@jmarantz @morlovich do either of you want to look at this more? |
- Improve shutting down both gracefully and quickly - Set the flush flags on buffers when FlushHtml is on for optimized html responses - Add tests for these features - Don't call proxy_fetch->Flush() each time our body filter is called, because that would only make sense if we'd also set buf->flush.
9eda614
to
7f7fd78
Compare
@jeffkaufman processed comments & force pushed |
Should I make a pull with the PSOL side needed for this to https://github.com/pagespeed/mod_pagespeed ? |
@oschaaf Yes! I'm glad to say we can accept pull requests to all of PageSpeed now! |
LGTM |
- Adds ProxyFetch::CancelOutstanding() which helps ngx_pagespeed with shutting down quickly by calling Done(false) on all live ProxyFetch instances. - Adds follow_flushes option, which makes ProxyFetch forward Flush calls to the RewriteDriver when set. These changes are needed for: apache/incubator-pagespeed-ngx#936
- Adds ProxyFetch::CancelOutstanding() which helps ngx_pagespeed with shutting down quickly by calling Done(false) on all live ProxyFetch instances. - Adds follow_flushes option, which makes ProxyFetch forward Flush calls to the RewriteDriver when set. These changes are needed for: apache/incubator-pagespeed-ngx#936
- Adds ProxyFetch::CancelOutstanding() which helps ngx_pagespeed with shutting down quickly by calling Done(false) on all live ProxyFetch instances. - Adds follow_flushes option, which makes ProxyFetch forward Flush calls to the RewriteDriver when set. These changes are needed for: apache/incubator-pagespeed-ngx#936
shutdown-and-flushing: Improve shutdown, support/test FlushHtml
Needs changes in PSOL, which are pending review.