This repository was archived by the owner on Apr 10, 2025. It is now read-only.
Repository navigation
This repository was archived by the owner on Apr 10, 2025. It is now read-only.
abort() when trying to revalidate expired output resource #1553
Copy link
Copy link
Closed
Description
I am using custom integration of PSOL and recently all instances started to crash with the same message:
[0605/094417:FATAL:output_resource.cc(223)] Output resources shouldn't be loaded via LoadAsync, but rather through FetchResource
Backtrace:
[Switching to Thread 0x7ffea2ffd700 (LWP 3018)]
base::debug::(anonymous namespace)::DebugBreak () at third_party/chromium/src/base/debug/debugger_posix.cc:246
246 }
(gdb) bt
#0 base::debug::(anonymous namespace)::DebugBreak () at third_party/chromium/src/base/debug/debugger_posix.cc:246
#1 0x0000000000b4a83d in base::debug::BreakDebugger () at third_party/chromium/src/base/debug/debugger_posix.cc:259
#2 0x000000000071cf7e in logging::LogMessage::~LogMessage (this=0x7ffea2ffbe20, __in_chrg=<optimized out>) at third_party/chromium/src/base/logging.cc:657
#3 0x00000000007a90c7 in net_instaweb::OutputResource::LoadAndCallback (this=0x7ffe94015868, not_cacheable_policy=net_instaweb::Resource::kReportFailureIfNotCacheable, request_context=...,
callback=0x7ffe94018498) at net/instaweb/rewriter/output_resource.cc:223
#4 0x00000000007add85 in net_instaweb::Resource::LoadAsync (this=0x7ffe94015868, not_cacheable_policy=net_instaweb::Resource::kReportFailureIfNotCacheable, request_context=..., callback=0x7ffe94018498)
at net/instaweb/rewriter/resource.cc:166
#5 0x0000000000bfd692 in net_instaweb::RewriteContext::OutputCacheRevalidate (this=0x7ffe9c038f68, to_revalidate=std::vector of length 1, capacity 1 = {...}) at net/instaweb/rewriter/rewrite_context.cc:1934
#6 0x0000000000bfbe96 in net_instaweb::RewriteContext::OutputCacheDone (this=0x7ffe9c038f68, cache_result=0x7ffe94016da8) at net/instaweb/rewriter/rewrite_context.cc:1674
#7 0x0000000000c10a9d in net_instaweb::MemberFunction1<net_instaweb::RewriteContext, net_instaweb::RewriteContext::CacheLookupResult*>::Run (this=0x7ffe94016f38) at ./pagespeed/kernel/base/function.h:171
#8 0x000000000089428f in net_instaweb::Function::CallRun (this=0x7ffe94016f38) at pagespeed/kernel/base/function.cc:51
#9 0x00000000006dde28 in net_instaweb::QueuedWorkerPool::Run (this=0x169b538, sequence=0x17884b8, worker=0x7ffe9c038528) at pagespeed/kernel/thread/queued_worker_pool.cc:157
#10 0x00000000006e5388 in net_instaweb::MemberFunction2<net_instaweb::QueuedWorkerPool, net_instaweb::QueuedWorkerPool::Sequence*, net_instaweb::QueuedWorker*>::Run (this=0x17afe08)
at ./pagespeed/kernel/base/function.h:202
#11 0x000000000089428f in net_instaweb::Function::CallRun (this=0x17afe08) at pagespeed/kernel/base/function.cc:51
#12 0x00000000006e9850 in net_instaweb::Worker::WorkThread::Run (this=0x7ffe9c03a2f8) at pagespeed/kernel/thread/worker.cc:84
#13 0x00000000006ecbab in net_instaweb::PthreadThreadImpl::InvokeRun (self_ptr=0x7ffe9c03a3c8) at pagespeed/kernel/thread/pthread_thread_system.cc:122
#14 0x00007ffff735c374 in start_thread (arg=0x7ffea2ffd700) at pthread_create.c:333
#15 0x00007ffff49d760f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:105
I've found metadata key it was using:
#5 0x0000000000bfd692 in net_instaweb::RewriteContext::OutputCacheRevalidate (this=0x7ffe9c038f68, to_revalidate=std::vector of length 1, capacity 1 = {...}) at net/instaweb/rewriter/rewrite_context.cc:1934
1934 new ResourceRevalidateCallback(this, resource, input_info));
(gdb) p partition_key_
$1 = "rname/ce_JfZ4rtPZUfry0kIJ6v3S/http://XXX/images/xpage1_img1.jpg.pagespeed.ic.965L1HZqE1.jpg@@_"
I've decoded InputInfo from that cache key and it was recently expired after being year in cache.
I'm using latest stable version of psol (1.11.33.4) but believe that last dev version still has the issue. It's also custom integration but I believe it doesn't matter. Well perhaps only except of long-living cache which helped to trigger the issue.
Metadata
Metadata
Assignees
Labels
No labels
Activity
oschaaf commentedon Jun 5, 2017
So far no luck hitting this code path with vanilla mod_pagespeed.
It looks like somehow
ResourcePtr resource = slots_[input_info->index()]->resource();returns anOutputResource, which I think should not happen: I think that should only resturnInputResources.So I wonder: how did the
OutputResourceend up there?cellscape commentedon Jun 5, 2017
I've tried to modify pagespeed to force return expired for every metadata cache lookup:
This way both my server and
pagespeed_automatic_testabort() with the same backtrace. Change itself is silly one but seems to do the job at least.This happens with both vanilla and patched pagespeed for me. I do have some modifications for PSOL and obviously there is integration step but changes do not seem to be related. I didn't touch rewriting at all, only cache/system stuff.
Can you reproduce above steps to confirm the issue on your side?
What happens in that test case I think is that cache extend filter requires already rewritten resource as input. It seems that
OutputResourceis being assigned to slot inRewriteContext::Propagate. After thatRewriteContext::RunSuccessorsstarts new rewrite withOutputResourcein cache. In test case above pagespeed first runs image compression filter and then cache extends it.RewriteContext::FetchInputshas comment saying about chained rewrites and requiring pagespeed resources as inputs.FetchInputsis called when metadata cache is missing at all for some input and it checks if URL of input is pagespeed URL, avoidingLoadAsyncfor such inputs and instead usingFetchResource.It seems that
RewriteContext::OutputCacheRevalidateshould do similar: if input is already rewritten then useFetchResource, otherwise fallback toLoadAsync.cellscape commentedon Jun 5, 2017
This triggers the issue with vanilla pagespeed without modification above.
jmarantz commentedon Jun 5, 2017
cellscape commentedon Jun 5, 2017
CacheHtmlFlow was just the first place where I observed the crash in tests with modification above. I just modified it to be able to reproduce quickly. It's in no way specific and I believe the issue is general one.
Basically this test does rewrite (with image compression to cache extender filter chain), expires stored metadata for
InputInfoand then aborts when trying to revalidate output of image compression. I might be wrong though, don't fully understand rewriting process.As for integration, I already described it some time ago on mailing list: https://groups.google.com/forum/#!msg/mod-pagespeed-discuss/_LJJ0UmQ8SU/sw5cvqedjmMJ. There probably were some changes but overall architecture is the same. As I said I don't think integration is to blame in that case though, we don't touch any rewriting or filters.
oschaaf commentedon Jun 5, 2017
This reproduces on master:
morlovich commentedon Jun 5, 2017
morlovich commentedon Jun 5, 2017
oschaaf commentedon Jun 5, 2017
I want to note that in release mode there is no abort, and with the simple test that excites this the results seem to look good
morlovich commentedon Jun 5, 2017
cellscape commentedon Jun 5, 2017
Looks like it's matter of having NDEBUG defined? This explains why nobody triggered that with apache or nginx then.
jmarantz commentedon Jun 5, 2017
oschaaf commentedon Jun 5, 2017
It sounds like in the short term what we could do is to remove the VLOG(DFATAL) with a warning for those running debug builds, and add a TODO for modifying
OutputResourceto indicate it is always valid as @morlovich suggested above? It would also be nice to include the new unit test.@cellscape Would you like to create a PR for this? :)
cellscape commentedon Jun 5, 2017
Is CLA still required? If yes then I pass otherwise will prepare one tomorrow.
oschaaf commentedon Jun 5, 2017
@cellscape a CLA is required.. so I'll create the PR then
Debug builds may abort() when revalidating expired output resources
Debug builds may abort() when revalidating expired output resources
Debug builds may abort() when revalidating expired output resources (#…
oschaaf commentedon Jul 7, 2017
Closing, as the fix for this was merged