Closed (fixed)
Project:
Purge
Version:
8.x-3.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
3 Aug 2020 at 13:45 UTC
Updated:
5 Mar 2026 at 11:45 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
rp7 commentedAfter some more research, I came to conclusion that the kernel.terminate event might be a better fit, since its called in all contexts.
Patch attached executes the late runtime processor when the kernel is being terminate. No visible issues so far (except that the visitor gets to see the response faster :) ).
Comment #3
rp7 commentedWith the patch in #2 we were seeing successful invalidations not being deleted from the queue. Appears the deletion of successful invalidations was being done before the actual invalidation. Fixed it & commented the code accordingly.
Comment #4
FleetAdmiralButter commented+1 on this. Running the late runtime processor during the TERMINATE event instead of the FINISH_REQUEST event would also avoid unnecessarily slowing down responses from Drupal. We've seen timeouts on sites with a large backlog in the purge queue.
Comment #5
japerryLooks good to me too. Committed to the 3.1 branch.
Comment #7
nielsvm commentedThank you for this reasonable improvement, I've committed your patch and released it:
https://www.drupal.org/project/purge/issues/3236847
Comment #8
moshe weitzman commentedThis will be quite a surprise for Drush users. I dont think it is expected that when you run an innocent command like drush status that a purge can be issued. I recommend rolling this back.
Comment #9
rp7 commentedCould you elaborate a little bit what kind of issues this can cause? A purge can be issued as well when visiting, for example, the status page through your browser. I'm having a hard time to see the difference?
Comment #10
moshe weitzman commentedThe cli is different than the web server. It is used for scripting auto action tasks where no human is present. There is no way arbitrary purges should be happening in these operations imo.
Comment #11
moshe weitzman commentedWe already have drush commands for purge. Just run those If you want to purge.
Comment #13
marcoscanoI wholeheartedly agree with #8 and #10 , the expectation IMHO is that a CLI execution should NOT trigger page-related events and process purger queues.
At the very minimum, this breaks sites using Config Split: #3264141: [REGRESSION] Purge 8.x-3.1+ incompatible with Config Split
Comment #14
rp7 commentedI guess it depends on the task? If you have a script that changes content (or a migration even?), and you want to prevent visitors from seeing stale content, you might very well want to?
FWIW there are other modules doing pretty much the same, Search API being one of them (https://git.drupalcode.org/project/search_api/-/blob/8.x-1.x/src/Utility...).
Don't get me wrong though, I can see valid points for both sides.
In hindsight, maybe we should have made this configurable at the very least.
As pointed at in my comment @ #3264141: [REGRESSION] Purge 8.x-3.1+ incompatible with Config Split, it's not the Purge module causing the
KernelEvents::TERMINATEto be triggered, it's drush.Comment #15
richardbporter commentedThis change also seems to result in diagnostic errors like the following printing to the console quite a bit with various Drush commands:
An example of when this can happen is syncing a site from another environment and then importing config which disables one purger and enables another (acquia_purge, varnish_purger).
Comment #16
richardbporter commentedOne thing I don't quite understand is why it was necessary to do this when the module purge_processor_cron already exists. If you want to purge through Drush, can't you just enable purge_processor_cron and schedule
drush croncalls regularly?Comment #17
rp7 commentedThey serve 2 completely different purposes. purge_processor_cron is interval based (every 15 minutes, for example). This ticket is about the late runtime processor, which is (nearly) instantaneous purging.
Comment #18
richardbporter commentedI think thats what was highlighted in https://www.drupal.org/project/purge/issues/3163002#comment-14246543. It seems like purge_processor_lateruntime was for web requests and purge_processor_cron was, indirectly, for the CLI via drush cron. At least they provided that option.
With this change, purge_processor_cron and the Drush commands specifically for purge have become somewhat irrelevant if purges will happen on any Drush command whatsoever.
Comment #19
rp7 commentedThe code nor documentation has any indiciation that the purge_processor_lateruntime was only meant for "web"-like requests. This is just an assumption of someone you happen to agree with.
As already mentioned in #14, I see valid points for both sides. Nevertheless, you are pointing to an "issue" that is not specific to Purge. There are probably a myriad of modules, such as Search API, which are doing "web"-like things in the Kernel::TERMINATE event. If this is incorrect (it may very well be, I don't know), either the use of Kernel::TERMINATE in all those modules should then be only limited to non-CLI requests (eg.
if (PHP_SAPI !== 'cli') { ... }) - and it should be documented somewhere - or the event shouldn't be triggered by drush at all (which is something you won't be able to tackle from this issue queue).Comment #20
kasperg commentedIn case someone is interested I have added support for configuring whether to disable the late runtime processor when running CLI commands in #3163002: Make late runtime processor compatible with drush.
Comment #21
achapI'm getting "MySQL server has gone away errors" after long running drush operations like search api indexing and running migrations with the lateruntime processor enabled. Those operations can put thousands of cache tags in the queue and it seems like it is trying to process many of them at the end of the request, or at the end of batches which is resulting in a packet size greater than max_allowed_packet. My max_allowed_packet setting is already quite high and I don't have much room to increase so I agree with the other comments that it would be better to at least have the option to disable it for CLI. Thanks for the MR @Kasperg
Comment #22
idebr commentedThe issue referenced in #20 is this issue. The correct issue is #3462078: Make late runtime processor configurable for CLI commands