You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Dropping a secondary index under load can crash the server #2251
Here's a scenario in which dropping a secondary index can lead to a server crash:
A snapshotted read R goes into the secondary index tree.
The secondary index is dropped. Dropping currently works in four steps:
2.1 remove the sindex from the sindex block
2.2 detach the sindex superblock
2.3 release the sindex block (so other queries can proceed)
2.4 actually delete all the blocks of the now detached sindex tree, detaching all referenced values
While the snapshotted read R is still active in the sindex tree and the sindex drop has just released the sindex block (2.3) but hasn't actually deleted all of the sindex tree yet (i.e. 2.4 is still ongoing), we delete a value from the table through the primary btree. The deletion will detach it in the primary btree and all indexes, and then actually delete the blocks associated with it. Since the sindex has already been removed from the sindex block in step 2.1, the blob will not be detached in the secondary index that's currently being dropped.
The snapshotted read R gets to a place in the secondary index that points to the blob deleted in step 3. It tries to load it. There is no snapshot of it, since 3 didn't detach it and the sindex deletion 2.4 hasn't got to it yet (otherwise it would have detached it). So it tries to load the current block which has been deleted in 3.
@srh also noted that our current way of dropping a secondary index can leave orphaned blocks that will never be freed behind, if the server crashes or is shut down in the middle of dropping a secondary index.
He proposed adding a third secondary index status to solve both of those problems. Right now a secondary index can be in post construction or ready. We would add a third state "being deleted".
Activity
danielmewes commentedon Apr 24, 2014
This requires changes to the disk format.
It will not be fixed for 1.12.x, but for 1.13.
danielmewes commentedon Apr 26, 2014
This is implemented in branch daniel_2251 (branched off v1.12.x), including a change that makes dropping secondary indexes actually delete the blocks.
Needs some more testing though.
danielmewes commentedon Apr 28, 2014
The changes are in CR 1462 by @srh
(some cleanup and small fixes still pending)
danielmewes commentedon May 28, 2014
The fix has been merged into next 7be2f23
It will ship with RethinkDB 1.13