The range deleter service service shutdown procedure is:
- Set the state as down
- ....do some more stuff....
- Turn off the range deletions processor
Hence when a range deletion throws IndexNotFound right while the service is stopping (between 1 and 3), it can happen that the processor tries to reschedule the task while the state is changing triggering this invariant.
The solution is to hold the proper locks when emplacing the range deletion as it happens here or to simply change emplaceRangeDeletions to result in a no-op when called while the service is not up.