1. Add an (enabled) index to a server.
  2. Disable the server: the index will be disabled, but Server::removeIndex() won't be called since the server is already marked as disabled internally.
  3. Remove the index from the server – again, since the server is disabled, Server::removeIndex() won't be called.
  4. Enable the server again. It now has no index anymore, without Server::removeIndex() ever having been called, possibly resulting in stale data or left-over tables.

Possible solution: call removeIndex() regardless of server status and move the status check there, moving the call to the pending server tasks if the server is currently disabled.
Alternately, we could there also check for $this->original->status() to see if we are currently in the process of disabling and, if we are, forward the call regardless. Might be a bit risky, though, depending on why the server is being disabled. But, since we have the same problem when deleting (even worse there, I guess, so at the time of disabling is probably the safer bet), it's also an idea.

In general, it seems the server doesn't check its own status at all, relying on the index to regard those restrictions (without them being documented anywhere, as far as I can see). Definitely also something to look into.

Estimated Value and Story Points

This issue was identified as a Beta Blocker for Drupal 8. We sat down and figured out the value proposition and amount of work (story points) for this issue.

Value and Story points are in the scale of fibonacci. Our minimum is 1, our maximum is 21. The higher, the more value or work a certain issue has.

Value : 2
Story Points: 3

Comments

drunken monkey’s picture

Project: Search API (8.x) » Search API
Version: » 8.x-1.x-dev
nick_vh’s picture

Issue summary: View changes
Issue tags: +beta blocker
drunken monkey’s picture

Component: Framework » Tests
Status: Active » Needs review
Issue tags: +DevDaysMilan
StatusFileSize
new4.95 KB

Seems like this has already been fixed at some point. But adding tests to verify this still seems like a good idea.

borisson_’s picture

Status: Needs review » Needs work
  1. +++ b/tests/src/Kernel/ServerChangesTest.php
    @@ -0,0 +1,142 @@
    +  /**
    +   * Modules to enable for this test.
    +   *
    +   * @var string[]
    +   */
    

    @inheritdoc

that's all I'd like to see changed.

  • drunken monkey committed ef1fbb8 on 8.x-1.x
    Issue #2318169 by drunken monkey: Added tests for Server::(add|remove)...
drunken monkey’s picture

Status: Needs work » Fixed

Thanks for the review, good that you spotted that mistake.
Fixed and committed.

Status: Fixed » Closed (fixed)

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