Skip to content

Dropping a secondary index under load can crash the server #2251

Closed

Description

@danielmewes

Discussed this with @srh earlier.

Here's a scenario in which dropping a secondary index can lead to a server crash:

  1. A snapshotted read R goes into the secondary index tree.
  2. 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
  3. 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.
  4. 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

  1. added this to the milestone on Apr 14, 2014
  2. self-assigned this
    on Apr 14, 2014
  3. danielmewes commented on Apr 24, 2014

    @danielmewes
    MemberAuthor

    This requires changes to the disk format.
    It will not be fixed for 1.12.x, but for 1.13.

  4. modified the milestones: 1.13, on Apr 24, 2014
  5. danielmewes commented on Apr 26, 2014

    @danielmewes
    MemberAuthor

    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.

  6. danielmewes commented on Apr 28, 2014

    @danielmewes
    MemberAuthor

    The changes are in CR 1462 by @srh
    (some cleanup and small fixes still pending)

  7. danielmewes commented on May 28, 2014

    @danielmewes
    MemberAuthor

    The fix has been merged into next 7be2f23

    It will ship with RethinkDB 1.13

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions