Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Principle:4paradigm OpenMLDB Rolling Upgrade

From Leeroopedia
Knowledge Sources
Domains Cluster_Operations, High_Availability
Last Updated 2026-10-12 12:00 GMT

Overview

A zero-downtime upgrade methodology that iteratively migrates leaders away from each tablet, upgrades its binary, and restores leaders — maintaining cluster availability throughout the process.

Description

Rolling upgrade in OpenMLDB uses a two-phase approach per tablet: PreUpgrade and PostUpgrade. PreUpgrade migrates all leader partitions from the target tablet to other healthy tablets, recording the migration state in a file. For single-replica partitions, it temporarily adds a replica to maintain availability. After the tablet binary is upgraded and restarted, PostUpgrade restores the leaders back to the upgraded tablet and removes any temporary replicas. This process is repeated for each tablet in the cluster, ensuring the cluster remains operational throughout.

The key problem solved is upgrade without downtime: in a replicated cluster, upgrading one tablet at a time while maintaining quorum and leader availability ensures continuous service.

Usage

Use this principle when upgrading OpenMLDB binaries in a production cluster. Process one tablet at a time: PreUpgrade → stop tablet → upgrade binary → restart tablet → PostUpgrade.

Theoretical Basis

Rolling upgrade follows the leader migration pattern:

Upgrade(Ti)=PreUpgrade(Ti)∘Stop(Ti)∘Replace(Ti)∘Start(Ti)∘PostUpgrade(Ti)

Pseudo-code for rolling upgrade:

# Abstract algorithm (NOT real implementation)
def rolling_upgrade(cluster, new_binary):
    for tablet in cluster.tablets:
        # Phase 1: Migrate leaders away
        leaders = get_leader_partitions(tablet)
        for partition in leaders:
            if partition.replica_count == 1:
                add_replica(partition, other_tablet)
            change_leader(partition, other_tablet)
        save_state(statfile, leaders)

        # Phase 2: Upgrade
        stop(tablet)
        replace_binary(tablet, new_binary)
        start(tablet)

        # Phase 3: Restore leaders
        wait_all_ops_done(cluster)
        for partition in load_state(statfile):
            change_leader(partition, tablet)
            if partition.was_single_replica:
                del_replica(partition, other_tablet)
        remove(statfile)

Practical Guide

  • Always disable auto-failover before starting the upgrade process
  • Process one tablet at a time — never upgrade multiple tablets simultaneously
  • The --statfile parameter tracks which leaders were migrated (default: .stat)
  • The --allow_single_replica flag skips single-replica tables (risky — they become unavailable)
  • PostUpgrade waits for all pending operations to complete before restoring leaders
  • Verify cluster health after each tablet upgrade

Related Pages

Implemented By

Uses Heuristic

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment