At runtime track URLs that have already been queued and skip those.

Created on 3 February 2018, over 6 years ago
Updated 25 October 2023, 8 months ago

invalidateTags(array $tags) can be called multiple times during serving a page. This function has a check inside to avoid processing the same tag twice (through $this->invalidatedTags).

The issue occurs when there are pages with multiple tags invalidated during current page processing.

E.g.:

  1. On a fresh installation with Purge and URLs queuer configured.
  2. Go to /admin/structure/block
  3. Toggle Powered by Drupal block Enabled/Disabled state
  4. At least the two following tags will be invalidated config:block.block.bartik_footer and config:block_list
  5. This in turn will cause the issue to occur.

Issue

All the pages with footer (meaning all the pages on the website) will be queued for purging twice. One time when the 1st tag is being processed and the once more when the 2nd one is passed to invalidateTags(array $tags).

Proposed solution

Add a something similar to $this->invalidatedTags array and keep queued URLs there. Then skip queuing any URL found in that array.

Thoughts?

πŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡·πŸ‡ΊRussia Georgii

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡³πŸ‡ΏNew Zealand ericgsmith

    I'm going to reopen this as I believe the original request has merit as a work around until a more clear solution is propose for 2851893.

    While 2851893 focuses on duplicate queued items - there is a valid issue with the original report of duplicate queued items in the same request, as the buffer does not deduplicate items (noted in https://www.drupal.org/project/purge/issues/2851893#comment-15182977 ✨ Deduplicate Queued Items Active )

    Importing config is one scenario we hit where memory limits got hit after importing a very large number of config changes.

    Attached is a patch that does what was originally suggested - track the purged urls of the request in a similar way to how invalidated tags are tracked.

    This deduplicates items in the buffer, but if you are concerned about duplicate items in the queue (from previous/subsequent requests) you will need additional solutions such as those suggested in 2851893.

    I haven't added a test with this patch but can share my local test using a similar scenario as described in the issue summary.

    Setup:

    1. Added 6 blocks all set to show on all pages, exported config
    2. Generated 30,000 items in the traffic registry using block list and the individual block tags
    3. Change the weight (in config) for the 6 blocks
    4. Import config with drush -vvv cim

    Without the patch:

      [debug] Calling Drush\Drupal\Commands\config\ConfigImportCommands::doImport(Drupal\Core\Config\StorageComparer) [4.89 sec, 114.07 MB]
     [notice] Synchronized configuration: update block.block.block_1. [8.12 sec, 208.87 MB]
     [notice] Synchronized configuration: update block.block.block_2. [9.19 sec, 242.77 MB]
     [notice] Synchronized configuration: update block.block.block_3. [10.21 sec, 286.69 MB]
     [notice] Synchronized configuration: update block.block.block_4. [11.28 sec, 321.07 MB]
     [notice] Synchronized configuration: update block.block.block_5. [12.38 sec, 356.42 MB]
     [notice] Synchronized configuration: update block.block.block_6. [13.48 sec, 390.32 MB]
     [notice] Finalizing configuration synchronization. [14.41 sec, 395.7 MB]
     [success] The configuration was imported successfully. [14.41 sec, 395.77 MB]
    

    Repeated with the patch:

     [debug] Calling Drush\Drupal\Commands\config\ConfigImportCommands::doImport(Drupal\Core\Config\StorageComparer) [5.07 sec, 114.64 MB]
     [notice] Synchronized configuration: update block.block.block_1. [7.67 sec, 172.27 MB]
     [notice] Synchronized configuration: update block.block.block_1. [8.38 sec, 172.52 MB]
     [notice] Synchronized configuration: update block.block.block_1. [9.03 sec, 172.68 MB]
     [notice] Synchronized configuration: update block.block.block_1. [9.71 sec, 173.42 MB]
     [notice] Synchronized configuration: update block.block.block_1. [10.38 sec, 175.12 MB]
     [notice] Synchronized configuration: update block.block.block_1. [11.04 sec, 175.39 MB]
     [notice] Finalizing configuration synchronization. [11.96 sec, 180.77 MB]
     [success] The configuration was imported successfully. [11.96 sec, 180.83 MB]
    

    This is only for 6 blocks - so you can imagine the imapct for much larger deployment sets.

  • Status changed to RTBC 11 months ago
  • πŸ‡³πŸ‡ΏNew Zealand RoSk0 Wellington

    The patch looks simple and elegant , thanks Eric.

    Works as expected.

  • πŸ‡³πŸ‡ΏNew Zealand ericgsmith
  • @ericgsmith opened merge request.
  • Status changed to Fixed 8 months ago
  • πŸ‡³πŸ‡ΏNew Zealand ericgsmith
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.69.0 2024