Currently, I don't think we really take care of enabled and disabled modules in any way. In D7, we currently mark modules as required by Drupal when they provide a service class (now: backend plugin) or datasource we are using in a server or index (like the Fields module does with modules defining used fields). Before that, I think we tried to delete indexes/servers when the module which provided their datasource/service class disappeared.

One of these two should also be done in D8 (or maybe some third option).

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Berdir’s picture

Core has a very strict dependency system for config, and each config entity can depend on N modules and other config entities. This ensures that configuration is automatically removed when dependencies are removed (This is unfortunately very strict, the nice thing is that it shows you on the uninstall screen what it will remove).

The system will also ensure that configuration is installed/synced in the right order, which is currently a problem. So we should make the index depend on the server (right now indexes are installed before servers because it's alphabetical if there is no explicit dependency) and things like fields, plugin providers and so on. Entity form/view displays are relatively complex core examples (calculateDependencies() Figuring that out will not be trivial, as we'll need to ask the data source what dependencies we have through the enabled fields...

amateescu’s picture

Assigned: Unassigned » amateescu

Me and @Berdir were just discussing this problem a few hours ago :) The index not depending on the server is fixed in #2257095: The database backend doesn't create columns when servers and indexes are created from default config because it was needed in order to fix the first bug there, and I'll work on the remaining problems.

amateescu’s picture

drunken monkey’s picture

Ah, excellent, great to hear!
I was aware of this core feature, yes, I just didn't know if we are using it (or if that's unavoidable).
Also, for us I think it wouldn't be appropriate to delete indexes when one datasource plugin or the current tracker plugin got removed. So, is there any way to avoid this?
(Also, would the dependency mean that when the Solr module gets uninstalled, all indexes lying on a Solr server would get deleted as well? That would be something we should definitely try to avoid, or at least warn against.)

amateescu’s picture

FileSize
7.59 KB

Here's a patch which makes Index and Server return all their dependencies, including field and instance config entities coming from each datasource of an index.

I'll think about how to best handle #4 after lunch :)

Berdir’s picture

Yay!

I can confirm that with the patch, I can add an index with server to the default config folder of a module/profile which already contains fields that the index depends on, which didn't work before.

I did notice a few things when testing, but they're not related to this issue I think, will open separate issues where it makes sense/when I can reproduce:

1. Looks like hook_cron() doesn't work yet, because things aren't indexed when I run cron?
2. Sometimes I get weird errors/exceptions because the server forgets about the index or something, then I had to edit, remove server, edit again, add server and then enable again, then it worked again.
3. Those edits and it not working initially resulted in my tables getting numeric suffixes, for example, I have now tables like search_api_db_{index}_1, and some field tables had up to _4 as a suffix, interestingly, despite that then being the default config after I re-installed, it went back to no suffix except the index table?

Berdir’s picture

Re #4:

I don't think it deletes automatically right now except when you uninstall a module, then it explicitly looks at your configuration dependencies and tells you what it is going to remove. See screenshot (the configuration fieldset is hidden by default, though)

We can use that dependency API on the delete confirmation form to easily find the indexes that depend on us and then remove them from the server (as we do now, except the UI part?)

I don't think we can prevent this if modules are uninstalled that provide processors or fields, though. Will ask @alexpott to comment...

amateescu’s picture

Status: Active » Needs review
FileSize
13.9 KB

Removed manual creation of fields and instances from SearchApiDbTest in favor of default config files.

The problem described in #4 is not really about the delete confirmation form, but about that screenshot posted in #7, where we don't want to remove the index when a module that contains its server backeng is uninstalled. I'm not sure what to do there, we do need the dependency at install time, but we don't want it (somehow) at uninstall time.

I'll wait for some advice from @alexpott on how we can do that :)

Berdir’s picture

amateescu’s picture

Assigned: amateescu » Unassigned
Status: Needs review » Postponed

I looked into solving the backend-providing-module uninstall problem and it's not possible without the core issue that @Berdir mentioned above.I'm going to commit this patch so we have proper dependencies declared now and mark this issue postponed to implement the self-healing process when we have it :)

  • Commit 0e02b6a on master by amateescu:
    Issue #2257081 by amateescu: Make sure to handle uninstalled modules...
amateescu’s picture

  • Commit 0e02b6a on master, htmlfilter by amateescu:
    Issue #2257081 by amateescu: Make sure to handle uninstalled modules...

  • Commit 0e02b6a on master, htmlfilter, 2235381-fix-config-schemas by amateescu:
    Issue #2257081 by amateescu: Make sure to handle uninstalled modules...

  • Commit 0e02b6a on master, htmlfilter, 2235381-fix-config-schemas, move-integration-tests-subfolder by amateescu:
    Issue #2257081 by amateescu: Make sure to handle uninstalled modules...

  • Commit 0e02b6a on master, htmlfilter, 2235381-fix-config-schemas, move-integration-tests-subfolder, 2230881-test-all-processors by amateescu:
    Issue #2257081 by amateescu: Make sure to handle uninstalled modules...

  • Commit 0e02b6a on master, htmlfilter, 2235381-fix-config-schemas, move-integration-tests-subfolder, issue-2273743 by amateescu:
    Issue #2257081 by amateescu: Make sure to handle uninstalled modules...

  • Commit 0e02b6a on master, htmlfilter, 2235381-fix-config-schemas, move-integration-tests-subfolder, issue-2273743, 2268885-fix-validation by amateescu:
    Issue #2257081 by amateescu: Make sure to handle uninstalled modules...

  • Commit 0e02b6a on master, htmlfilter, 2235381-fix-config-schemas, move-integration-tests-subfolder, issue-2273743, 2268885-fix-validation, synonyms-processor, 2230925-server-tasks by amateescu:
    Issue #2257081 by amateescu: Make sure to handle uninstalled modules...

  • Commit 0e02b6a on master, htmlfilter, 2235381-fix-config-schemas, move-integration-tests-subfolder, issue-2273743, 2268885-fix-validation, synonyms-processor, 2230925-server-tasks, 2235381-fix-config-schemas-2 by amateescu:
    Issue #2257081 by amateescu: Make sure to handle uninstalled modules...

  • Commit 0e02b6a on master, htmlfilter, move-integration-tests-subfolder, issue-2273743, 2268885-fix-validation, synonyms-processor, 2230925-server-tasks, 2235381-fix-config-schemas-2, 2257113-Index-Processors-Fields by amateescu:
    Issue #2257081 by amateescu: Make sure to handle uninstalled modules...

  • Commit 0e02b6a on master, htmlfilter, move-integration-tests-subfolder, issue-2273743, 2268885-fix-validation, synonyms-processor, 2230925-server-tasks, 2235381-fix-config-schemas-2, 2257113-Index-Processors-Fields by amateescu:
    Issue #2257081 by amateescu: Make sure to handle uninstalled modules...

  • Commit 0e02b6a on master, htmlfilter, move-integration-tests-subfolder, issue-2273743, 2268885-fix-validation, synonyms-processor, 2230925-server-tasks, 2235381-fix-config-schemas-2, 2257113-Index-Processors-Fields, config-schema by amateescu:
    Issue #2257081 by amateescu: Make sure to handle uninstalled modules...

  • Commit 0e02b6a on master, htmlfilter, move-integration-tests-subfolder, issue-2273743, 2268885-fix-validation, synonyms-processor, 2230925-server-tasks, 2235381-fix-config-schemas-2, 2257113-Index-Processors-Fields, config-schema, transliteration by amateescu:
    Issue #2257081 by amateescu: Make sure to handle uninstalled modules...

  • Commit 0e02b6a on master, htmlfilter, move-integration-tests-subfolder, issue-2273743, 2268885-fix-validation, synonyms-processor, 2230925-server-tasks, 2235381-fix-config-schemas-2, 2257113-Index-Processors-Fields, config-schema, transliteration, ignore-case-test-fix by amateescu:
    Issue #2257081 by amateescu: Make sure to handle uninstalled modules...

  • Commit 0e02b6a on master, htmlfilter, move-integration-tests-subfolder, issue-2273743, 2268885-fix-validation, synonyms-processor, 2230925-server-tasks, 2235381-fix-config-schemas-2, 2257113-Index-Processors-Fields, config-schema, transliteration, ignore-case-test-fix, 2281233-fix-stopwords by amateescu:
    Issue #2257081 by amateescu: Make sure to handle uninstalled modules...

  • Commit 0e02b6a on master, htmlfilter, move-integration-tests-subfolder, issue-2273743, 2268885-fix-validation, synonyms-processor, 2230925-server-tasks, 2235381-fix-config-schemas-2, 2257113-Index-Processors-Fields, config-schema, transliteration, ignore-case-test-fix, 2281233-fix-stopwords, ignorecase-nick, renamefields by amateescu:
    Issue #2257081 by amateescu: Make sure to handle uninstalled modules...

  • Commit 0e02b6a on master, htmlfilter, move-integration-tests-subfolder, issue-2273743, 2268885-fix-validation, synonyms-processor, 2230925-server-tasks, 2235381-fix-config-schemas-2, 2257113-Index-Processors-Fields, config-schema, transliteration, ignore-case-test-fix, 2281233-fix-stopwords, ignorecase-nick, renamefields by amateescu:
    Issue #2257081 by amateescu: Make sure to handle uninstalled modules...

  • Commit 0e02b6a on master, htmlfilter, issue-2273743, 2268885-fix-validation, synonyms-processor, 2235381-fix-config-schemas-2, config-schema, transliteration, ignore-case-test-fix, ignorecase-nick, renamefields, highlight by amateescu:
    Issue #2257081 by amateescu: Make sure to handle uninstalled modules...

  • Commit 0e02b6a on master, htmlfilter, issue-2273743, 2268885-fix-validation, synonyms-processor, 2235381-fix-config-schemas-2, config-schema, transliteration, ignore-case-test-fix, ignorecase-nick, renamefields, highlight, add-aggregation-nick by amateescu:
    Issue #2257081 by amateescu: Make sure to handle uninstalled modules...

  • Commit 0e02b6a on master, htmlfilter, issue-2273743, 2268885-fix-validation, synonyms-processor, 2235381-fix-config-schemas-2, config-schema, transliteration, ignore-case-test-fix, ignorecase-nick, renamefields, highlight, add-aggregation-nick, 2247923-Test_the_RenderedItem_processor by amateescu:
    Issue #2257081 by amateescu: Make sure to handle uninstalled modules...

  • Commit 0e02b6a on master, htmlfilter, issue-2273743, 2268885-fix-validation, synonyms-processor, 2235381-fix-config-schemas-2, config-schema, transliteration, ignore-case-test-fix, ignorecase-nick, renamefields, highlight, add-aggregation-nick, 2247923-Test_the_RenderedItem_processor, 2286813-fields-processor-plugin-base-test by amateescu:
    Issue #2257081 by amateescu: Make sure to handle uninstalled modules...

  • amateescu committed 0e02b6a on add_aggregatedfield_test
    Issue #2257081 by amateescu: Make sure to handle uninstalled modules...
Berdir’s picture

Status: Postponed » Active

20 commit references later, the core issue finally made it in, so we can unpostpone this and implement the new method. See changes to EntityDisplayBase in #2260457: Allow config entities to remove dependent configuration keys when dependencies are deleted due to module uninstall as an example.

drunken monkey’s picture

Excellent, good to know!
Maybe something to tackle in Amsterdam – unless someone wants to take a shot at it before then.

  • amateescu committed 0e02b6a on 2349435-seperate-processors-by-stage
    Issue #2257081 by amateescu: Make sure to handle uninstalled modules...
drunken monkey’s picture

Project: Search API (8.x) » Search API
Version: » 8.x-1.x-dev
Priority: Normal » Major
drunken monkey’s picture

Status: Active » Closed (duplicate)

Already implemented this in some other issue(s).