Config import sometimes needs be run several times to fully sync

Created on 7 October 2021, about 3 years ago
Updated 27 February 2023, almost 2 years ago

Problem/Motivation

Under some circumstances, the configuration import process must be run multiple times for configuration to be fully synced.

There was in-depth discussion where we attempted to solve this in the drush issue queue. Ultimately it was decided that we needed to move this to a core issue though.

In the past I have solved this by simply including drush config:import twice in the deploy scripts. However, we recently switched to using drush deploy and that resurfaced the issue as drush deploy only imports configuration once.

While we often see this issue with drush, this is really an issue with the config import process. Config has to be imported twice regardless of if drush or the config UI is used (I confirmed this for my use case explained below).

The specifics of the modules used might not be important, as I've seen this happen with config split (issues linked below) and now the layout_builder_restrictions module as well. It's also possible that the outcome of this issue is that the modules need to manage their own configuration better, but I'm not sure what should be done differently if that is the case.

Related issues:

Steps to reproduce

Modules:

drupal/core-recommended: 8.9.7
drush/drush: 10.3.5
drupal/layout_builder_restrictions: 2.7.0

Steps:

  1. Run drush config:import and confirm it imports everything.
  2. Run drush config:export and confirm no changes are present.
  3. Enable layout builder for a content type and save the form (/admin/structure/types/manage/article/display).
  4. Enable per content type block restrictions and save the form (/admin/structure/types/manage/article/display).
  5. Run drush config:export and commit the config diff.
  6. Grab a fresh database locally or attempt to deploy this to a new database in a different environment.
  7. Run drush config:import
  8. Run drush config:export and see a diff.

Proposed resolution

Possible options:

  1. Document that running the import process twice is the official recommended process.
  2. Adjust the config import process to import config twice in the background, but only require the command to run once.
  3. Adjust the config import process to import configuration tagged "critical" first or some sort of prioritization process. (https://github.com/drush-ops/drush/issues/2449#issuecomment-764849648 & https://github.com/drush-ops/drush/issues/2449#issuecomment-774031495)
  4. "Maybe we could do a 're-try' option that imports config x times if there are still changes to import?" (https://github.com/drush-ops/drush/issues/2449#issuecomment-812915964)
  5. Something else that I haven't even thought of?

Option #3 seems like the best approach with the knowledge I have now, but I'm very open to other ideas.

If we go this route, I assume the logic would go somewhere around here.

Thank you to everyone who chimed in on the original GitHub issue with ideas, as many of these ideas are taken from others.

Remaining tasks

  • Fully understand the issue.
  • Decide where this should be addressed.
  • Decide how this should be fixed.

User interface changes

N/A

API changes

Hopefully N/A

Data model changes

N/A

Release notes snippet

Under some circumstances config would previously need to be imported twice to be fully synced. Additional config imports are no longer needed wether it is via Drush or the UI, and a single config import call should result in configuration being fully synced.

πŸ› Bug report
Status

Active

Version

10.1 ✨

Component
ConfigurationΒ  β†’

Last updated 3 days ago

Created by

πŸ‡ΊπŸ‡ΈUnited States adamzimmermann

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.

  • πŸ‡ΊπŸ‡ΈUnited States j.cowher

    I am also experiencing this with a core.entity_view_display.* config file. I am on Drupal 9.5.3.

    Original components:

              57de20b1-6a3b-4491-ba6d-7d4ce5dfa3c0:
                uuid: 57de20b1-6a3b-4491-ba6d-7d4ce5dfa3c0
                region: content
                configuration:
                  id: 'field_block:media:ceros:field_media_ceros'
                  label_display: '0'
                  context_mapping:
                    entity: layout_builder.entity
                  formatter:
                    type: ceros_embed
                    label: hidden
                    settings: {  }
                    third_party_settings:
                      fences:
                        fences_field_tag: div
                        fences_field_classes: ''
                        fences_field_item_tag: div
                        fences_field_item_classes: ''
                        fences_label_tag: div
                        fences_label_classes: ''
                      field_display_label_override:
                        label_value: ''
                      ds:
                        ft:
                          id: default
                          settings:
                            lb: ''
                            lb-col: false
                            classes: {  }
                weight: 0
                additional: {  }
              f4978e4b-d0fe-4629-b332-7b5e76085334:
                uuid: f4978e4b-d0fe-4629-b332-7b5e76085334
                region: content
                configuration:
                  id: 'field_block:media:ceros:field_media_section'
                  label_display: '0'
                  context_mapping:
                    entity: layout_builder.entity
                  formatter:
                    type: entity_reference_label
                    label: visually_hidden
                    settings:
                      link: true
                    third_party_settings: {  }
                weight: 1
                additional: {  }
              89dfd115-9472-4185-9898-a72cc26ed7f0:
                uuid: 89dfd115-9472-4185-9898-a72cc26ed7f0
                region: content
                configuration:
                  id: 'field_block:media:ceros:field_segment'
                  label_display: '0'
                  context_mapping:
                    entity: layout_builder.entity
                  formatter:
                    type: entity_reference_label
                    label: visually_hidden
                    settings:
                      link: true
                    third_party_settings: {  }
                weight: 2
                additional: {  }
              5b8a2898-1eac-4756-bf29-286741c47cdb:
                uuid: 5b8a2898-1eac-4756-bf29-286741c47cdb
                region: content
                configuration:
                  id: 'field_block:media:ceros:field_media_audience'
                  label_display: '0'
                  context_mapping:
                    entity: layout_builder.entity
                  formatter:
                    type: entity_reference_label
                    label: visually_hidden
                    settings:
                      link: true
                    third_party_settings: {  }
                weight: 3
                additional: {  }
            third_party_settings: {  }
    

    After export:

              57de20b1-6a3b-4491-ba6d-7d4ce5dfa3c0:
                uuid: 57de20b1-6a3b-4491-ba6d-7d4ce5dfa3c0
                region: content
                configuration:
                  id: 'field_block:media:ceros:field_media_ceros'
                  label_display: '0'
                  context_mapping:
                    entity: layout_builder.entity
                  formatter:
                    type: ceros_embed
                    label: hidden
                    settings: {  }
                    third_party_settings:
                      fences:
                        fences_field_tag: div
                        fences_field_classes: ''
                        fences_field_item_tag: div
                        fences_field_item_classes: ''
                        fences_label_tag: div
                        fences_label_classes: ''
                      field_display_label_override:
                        label_value: ''
                      ds:
                        ft:
                          id: default
                          settings:
                            lb: ''
                            lb-col: false
                            classes: {  }
                weight: 0
                additional: {  }
              f4978e4b-d0fe-4629-b332-7b5e76085334:
                uuid: f4978e4b-d0fe-4629-b332-7b5e76085334
                region: content
                configuration:
                  id: 'field_block:media:ceros:field_media_section'
                  label_display: '0'
                  context_mapping:
                    entity: layout_builder.entity
                  formatter:
                    type: entity_reference_label
                    label: visually_hidden
                    settings:
                      link: true
                    third_party_settings: {  }
                weight: 1
                additional: {  }
              89dfd115-9472-4185-9898-a72cc26ed7f0:
                uuid: 89dfd115-9472-4185-9898-a72cc26ed7f0
                region: content
                configuration:
                  id: 'field_block:media:ceros:field_segment'
                  label_display: '0'
                  context_mapping:
                    entity: layout_builder.entity
                  formatter:
                    type: entity_reference_label
                    label: visually_hidden
                    settings:
                      link: true
                    third_party_settings: {  }
                weight: 2
                additional: {  }
              5b8a2898-1eac-4756-bf29-286741c47cdb:
                uuid: 5b8a2898-1eac-4756-bf29-286741c47cdb
                region: content
                configuration:
                  id: 'field_block:media:ceros:field_media_audience'
                  label_display: '0'
                  context_mapping:
                    entity: layout_builder.entity
                  formatter:
                    type: entity_reference_label
                    label: visually_hidden
                    settings:
                      link: true
                    third_party_settings: {  }
                weight: 3
                additional: {  }
            third_party_settings: {  }
              b5b288aa-f620-4057-a9cb-7cc15d7353fa:
                uuid: b5b288aa-f620-4057-a9cb-7cc15d7353fa
                region: content
                configuration:
                  id: 'field_block:media:ceros:field_media_ceros'
                  label_display: '0'
                  context_mapping:
                    entity: layout_builder.entity
                  formatter:
                    type: ceros_embed
                    label: hidden
                    settings: {  }
                    third_party_settings:
                      fences:
                        fences_field_tag: div
                        fences_field_classes: ''
                        fences_field_item_tag: div
                        fences_field_item_classes: ''
                        fences_label_tag: div
                        fences_label_classes: ''
                      field_display_label_override:
                        label_value: ''
                      ds:
                        ft:
                          id: default
                          settings:
                            lb: ''
                            lb-col: false
                            classes: {  }
                weight: 4
                additional: {  }
              20cf119d-161a-49bb-86af-4e62f1068166:
                uuid: 20cf119d-161a-49bb-86af-4e62f1068166
                region: content
                configuration:
                  id: 'field_block:media:ceros:field_media_section'
                  label_display: '0'
                  context_mapping:
                    entity: layout_builder.entity
                  formatter:
                    type: entity_reference_label
                    label: visually_hidden
                    settings:
                      link: true
                    third_party_settings: {  }
                weight: 5
                additional: {  }
              7574088f-dc33-4837-b4ba-94b51d1f1184:
                uuid: 7574088f-dc33-4837-b4ba-94b51d1f1184
                region: content
                configuration:
                  id: 'field_block:media:ceros:field_segment'
                  label_display: '0'
                  context_mapping:
                    entity: layout_builder.entity
                  formatter:
                    type: entity_reference_label
                    label: visually_hidden
                    settings:
                      link: true
                    third_party_settings: {  }
                weight: 6
                additional: {  }
              c510be7f-1971-4a7a-adeb-3e7ee589af42:
                uuid: c510be7f-1971-4a7a-adeb-3e7ee589af42
                region: content
                configuration:
                  id: 'field_block:media:ceros:field_media_audience'
                  label_display: '0'
                  context_mapping:
                    entity: layout_builder.entity
                  formatter:
                    type: entity_reference_label
                    label: visually_hidden
                    settings:
                      link: true
                    third_party_settings: {  }
                weight: 7
                additional: {  }
            third_party_settings: {  }
    

    After importing and then exporting it appears that blocks are being duplicated with new uuids, but the existing blocks aren't being removed. It doesn't matter how many times I import and export there is always a diff with "new" blocks.

Production build 0.71.5 2024