If a datasource gets removed from an index, corresponding entities are deleted from the index. But their field configurations remain in an illegal state once the index entity is loaded again from the database.

I suggest to remove all field configurations from an index that depend on a removed datasource.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mkalkbrenner created an issue. See original summary.

mkalkbrenner’s picture

Status: Active » Needs review
FileSize
1.08 KB

Status: Needs review » Needs work

The last submitted patch, 2: 2761719_failing_test.patch, failed testing.

mkalkbrenner’s picture

mkalkbrenner’s picture

I think this version of the patch better demonstrates the issue and is closer to the use case we have in the Solr backend.

mkalkbrenner’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 5: 2761719_failing_test-5.patch, failed testing.

mkalkbrenner’s picture

Title: Removal of datasource leads to illegal field states » Removal of datasource leads to left over illegal field configurations
Issue summary: View changes
Priority: Major » Critical
Issue tags: +beta blocker
drunken monkey’s picture

Thanks a lot for reporting this, it's indeed a pretty big problem. It also occurs when removing a processor that defines a field. The solution will probably be for both problems, though: when saving the index, just get all properties and check that all fields correspond to one of them.

drunken monkey’s picture

mkalkbrenner’s picture

Status: Closed (duplicate) » Needs review

The issue is not solved by the other one.

Status: Needs review » Needs work

The last submitted patch, 5: 2761719_failing_test-5.patch, failed testing.

mkalkbrenner’s picture

Status: Needs work » Needs review

The test only patch still demonstrates the issue.

mkalkbrenner’s picture

Status: Needs review » Needs work
drunken monkey’s picture

You're right, this still leads to errors, even though the bug is now a different one.
The attached patch should fix this, and provide a proper test.

mkalkbrenner’s picture

Status: Needs review » Needs work

The patch improves the situation. But now the tests in search_api_solr fail on the next query because $query->getSorts() seems to still return the old fields.

drunken monkey’s picture

Status: Needs work » Needs review

The patch improves the situation. But now the tests in search_api_solr fail on the next query because $query->getSorts() seems to still return the old fields.

Could you please elaborate on that? What "next query"? What "$query->getSorts()"? And why would getSorts() have anything to do with this issue – that's a simple getter which returns the exact information you put into it before, without any regards to the index's field (or any other) settings.

Also, again, failing Solr tests are no grounds for rejection of a patch here. Either tell me what's wrong with the patch itself, regarding just Search API, or fix Solr to work with it.

mkalkbrenner’s picture

Status: Needs review » Fixed

I think the issue isn't completely fixed. The broken solr tests are still broken in a part that only consists of calls to search api functions. So I think it's not solr related but discovers a remaining search api bug if a datasource gets removed. I'm currently trying to reproduce the issue in an search api only tests and will create another issue for that.

mkalkbrenner’s picture

Status: Fixed » Needs review

sorry, the issue hasn't been committed so far, so back to needs review.

mkalkbrenner’s picture

Status: Needs review » Reviewed & tested by the community

OK, I found the reason that still breaks the solr tests even with the proposed patch applied:

protected function buildSearch($keys = NULL, array $conditions = array(), array $fields = NULL, $place_id_sort = TRUE) {
    static $i = 0;

    ...

    if ($place_id_sort) {
      // Use the normal "id" and the magic "search_api_id" field alternately, to
      // make sure both work as expected.
      $query->sort((++$i % 2) ? 'id' : 'search_api_id');
    }

    return $query;
}

This function from the BackendTestBase randomly adds 'id' as sort parameter which doesn't exist anymore if datasource entity:entity_test_mulrev_changed gets removed. Due to that alteration between 'id' and 'search_api_id', the query worked on one index but failed on the second I use in the solr tests.

Please excuse the confusion. The patch solves the issue and is RTBC.

  • drunken monkey committed 6f160f9 on 8.x-1.x
    Issue #2761719 by drunken monkey, mkalkbrenner: Fixed removing of fields...
drunken monkey’s picture

Status: Reviewed & tested by the community » Fixed

OK, good to hear, thanks!
Committed.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.