Add state column in Search::Zoekt::Node

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

Proposal

Introduce a state column in Search::Zoekt::Node. The possible states are online, offline, lost and pending_deletion.

We can only allow nodes to go offline -> lost -> pending_deletion, but never from pending_deletion to other existing states.

The following discussion from !166481 (merged) should be addressed:

  • @mwoolf started a discussion: (+5 comments)

    I shared your concern here @rkumar555, so asked in #database for some guidance.

    @ahegyi Suggested that this approach would be "ok-ish" but that we should avoid long-running transactions where possible. Clearly the use of batches here will reduce the risk.

    The suggestion was to mark unused nodes as unused in this worker, and then delete the ActiveRecord objects async. Would that be possible? (I'm not familiar enough with Zoekt to have a strong opinion.) If not, then this approach would be acceptable.

Node state lifecycle

image

Edited by 🤖 GitLab Bot 🤖