bootstrap

package
v1.2.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 10, 2024 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAccountIdByName added in v1.2.0

func GetAccountIdByName(accountName string, txn executor.TxnExecutor) (int32, error)

GetAccountIdByName get accountId by accountName when upgrade account

Types

type Locker

type Locker interface {
	// Get return true means get lock
	Get(ctx context.Context, key string) (bool, error)
}

Locker locker is used to get lock to bootstrap. Only one cn can get lock to bootstrap. Other cns need to wait bootstrap completed.

type Option added in v1.2.0

type Option func(s *service)

Option option for bootstrap service

func WithCheckUpgradeDuration added in v1.2.0

func WithCheckUpgradeDuration(value time.Duration) Option

WithCheckUpgradeDuration setup check upgrade duration

func WithCheckUpgradeTenantDuration added in v1.2.0

func WithCheckUpgradeTenantDuration(value time.Duration) Option

WithCheckUpgradeDuration setup check upgrade duration

func WithCheckUpgradeTenantWorkers added in v1.2.0

func WithCheckUpgradeTenantWorkers(value int) Option

WithCheckUpgradeTenantWorkers setup upgrade tenant workers

func WithUpgradeHandles added in v1.2.0

func WithUpgradeHandles(handles []VersionHandle) Option

WithUpgradeHandles reset upgrade handles

func WithUpgradeTenantBatch added in v1.2.0

func WithUpgradeTenantBatch(value int) Option

WithUpgradeTenantBatch setup upgrade tenant batch

type Service added in v1.2.0

type Service interface {
	// Bootstrap try to bootstrap mo cluster
	Bootstrap(ctx context.Context) error
	// BootstrapUpgrade bootstrap upgrade framework
	BootstrapUpgrade(ctx context.Context) error
	// MaybeUpgradeTenant used to upgrade tenant metadata if the tenant is old version.
	// Return true, nil means tenant upgraded, the call need to load tenant again to get
	// latest tenant info.
	MaybeUpgradeTenant(
		ctx context.Context,
		tenantFetchFunc func() (int32, string, error),
		txnOp client.TxnOperator) (bool, error)
	// UpgradeTenant used to manual upgrade tenant metadata
	UpgradeTenant(ctx context.Context, tenantName string, retryCount uint32, isALLAccount bool) (bool, error)
	// GetFinalVersion Get mo final version, which is based on the current code
	GetFinalVersion() string
	// GetFinalVersionOffset Get mo final version offset, which is based on the current code
	GetFinalVersionOffset() int32
	// Close close bootstrap service
	Close() error
}

Service is used to bootstrap and upgrade mo cluster.

In bootstrap, it will create some internal databases and tables at the time of MO initialization according to a specific logic. It provides the necessary dependencies for other components to be launched later.

In upgrade, it will upgrade the metadata between two MO versions. When there is a need to modify the original data (e.g. create a system table, modify the system table structure, etc.) between two MO versions, then an upgrade process is required. This process is used to ensure that each tenant's data is properly upgraded and updated.

Note that, this service is not used to bootstrap logservice and dn. The internal databases and tables as below: 1. mo_indexes in mo_catalog 2. task infrastructure database

func NewService added in v1.2.0

func NewService(
	lock Locker,
	clock clock.Clock,
	client client.TxnClient,
	exec executor.SQLExecutor,
	opts ...Option) Service

NewService create service to bootstrap mo database

type VersionHandle added in v1.2.0

type VersionHandle interface {
	// Metadata version metadata
	Metadata() versions.Version
	// Prepare prepare upgrade. This upgrade will be executed before cluster and tenant upgrade.
	Prepare(ctx context.Context, txn executor.TxnExecutor, final bool) error
	// ClusterNeedUpgrade handle upgrade cluster metadata. This upgrade will be executed before
	// tenant upgrade.
	HandleClusterUpgrade(ctx context.Context, txn executor.TxnExecutor) error
	// HandleTenantUpgrade handle upgrade a special tenant.
	HandleTenantUpgrade(ctx context.Context, tenantID int32, txn executor.TxnExecutor) error
	// HandleCreateFrameworkDeps Used to execute pre dependencies when creating a new upgrade framework
	// based on the current version for the first time.
	HandleCreateFrameworkDeps(txn executor.TxnExecutor) error
}

VersionHandle every version that needs to be upgraded with cluster metadata needs to have an VersionHandle implementation!

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL