locale_translation queue loop

Created on 27 January 2020, over 5 years ago
Updated 30 January 2023, over 2 years ago

Problem/Motivation

Our locale_translation queue sometimes gets stuck in a loop because it contains locale_translation_batch_fetch_import batch jobs for translation projects that are already imported.

For example, we will have a row that looks like this in the queue table:

|  196933 | locale_translation | a:2:{i:0;s:37:"locale_translation_batch_fetch_import";i:1;a:4:{i:0;s:7:"metatag"...

Although this locale was already imported.

Because of this, the locale_translation_get_status() call at the beginning of locale_translation_batch_fetch_import() results in a current type source for this particular project.

locale_translation_batch_fetch_import() then checks if the source type is remote or local before doing anything. In our case, the source is current so the batch is never completed and it will keep recreating the same queue item forever.

Proposed resolution

I could not identify what creates these batch jobs, but the attached patch fixes the loop by ending the batch without doing anything when the source type is current.

πŸ› Bug report
Status

Needs work

Version

9.5

Component
Language systemΒ  β†’

Last updated about 8 hours ago

  • Maintained by
  • πŸ‡©πŸ‡ͺGermany @sun
Created by

πŸ‡«πŸ‡·France prudloff Lille

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

Merge Requests

Comments & Activities

Not all content is available!

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

  • The Needs Review Queue Bot β†’ tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

    Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

    Consult the Drupal Contributor Guide β†’ to find step-by-step guides for working with issues.

  • Status changed to Closed: outdated 2 months ago
  • πŸ‡«πŸ‡·France prudloff Lille

    I can still reproduce on Drupal 11.1.3 like this:

    1. Force translations to be fetched for a project.
      It can be simulated like this: delete the project item in locale.translation_status key/value storage and set the timestamp and last_checked columns to 0 in the locale_file table.
      I think it has to be a large project where the import will need multiple batch runs.
    2. Run the locale_cron cron to create items in the locale_translation queue
    3. Start running the locale_translation queue but abort when the locale_translation_batch_fetch_import batch is not finished
    4. Run drush locale-update.
      This will import the translation and mark it as current but leave your previous unfinished queue item.
    5. Run the locale_translation queue again: it now runs forever.

    I will try to write tests for this.

  • πŸ‡«πŸ‡·France prudloff Lille

    I think I closed this by mistake.

  • Pipeline finished with Success
    about 2 months ago
    Total: 1002s
    #456625
  • πŸ‡«πŸ‡·France prudloff Lille

    I added a test.

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave
    There was 1 failure:
    1) Drupal\Tests\locale\Kernel\LocaleBatchTest::testBuildProjects
    Failed asserting that null matches expected 1.
    /builds/issue/drupal-3109284/core/modules/locale/tests/src/Kernel/LocaleBatchTest.php:45
    --
    1 test triggered 1 PHP warning:
    1) /builds/issue/drupal-3109284/core/modules/locale/tests/src/Kernel/LocaleBatchTest.php:45
    Undefined array key "finished"
    Triggered by:
    * Drupal\Tests\locale\Kernel\LocaleBatchTest::testBuildProjects
      /builds/issue/drupal-3109284/core/modules/locale/tests/src/Kernel/LocaleBatchTest.php:28
    FAILURES!
    Tests: 1, Assertions: 1, Failures: 1, Warnings: 1.
    Exiting with EXIT_CODE=1
    

    Shows the test coverage

    Reviewing the actual code change and looks inline with how line 224 is being checked.

    LGTM

  • Status changed to Needs work 3 days ago
  • πŸ‡¬πŸ‡§United Kingdom catch

    One comment on the MR.

Production build 0.71.5 2024