Skip to content
This repository was archived by the owner on Jun 23, 2022. It is now read-only.

feat(dup): add init_duplicating on replica init info #351

Closed
wants to merge 2 commits into from

Conversation

neverchanje
Copy link

@neverchanje neverchanje commented Dec 6, 2019

Duplication requires mutation-logs never being cleaned until duplicated to ensure data consistency and safety. However, when replica re-bootstraps it may lose the memory and forget if it's in duplication.
Therefore, we should add a mark when duplication is assigned on each replica, and this mark should be persisted on disk for recovery.

class replica_init_info
{
public:
    ...
    bool init_duplicating;

So when this mark is used:

bool replica::is_duplicating() const { return _app->init_info().init_duplicating; }

void replica::on_checkpoint_timer()
    decree min_confirmed_decree = _duplication_mgr->min_confirmed_decree();
    decree cleanable_decree = last_durable_decree;
    if (min_confirmed_decree >= 0) {
        if (min_confirmed_decree < last_durable_decree) {
            cleanable_decree = min_confirmed_decree;
        }
    } else {
        // protect the logs from being truncated
        // if this app is in duplication
        if (is_duplicating()) {
            // unsure if the logs can be dropped, because min_confirmed_decree
            // is currently unavailable
            return;
        }
    }
}

And when this mark is set:

void replica_duplicator_manager::update_confirmed_decree_if_secondary(decree confirmed)
{
    ...
    _replica->update_init_info_duplicating(confirmed >= 0);
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant