MCPcopy Create free account
hub / github.com/bytebase/bytebase / waitStarRocksReady

Function waitStarRocksReady

backend/common/testcontainer/testcontainer.go:347–361  ·  view source on GitHub ↗

waitStarRocksReady blocks until at least one StarRocks backend is registered and alive, which is required before tablet-allocating DDL (CREATE TABLE) succeeds. The check is read-only on purpose: issuing DDL during allin1's first-boot disrupts backend registration, so poll SHOW BACKENDS rather than p

(ctx context.Context, db *sql.DB)

Source from the content-addressed store, hash-verified

345// read-only on purpose: issuing DDL during allin1's first-boot disrupts backend
346// registration, so poll SHOW BACKENDS rather than probing with CREATE TABLE.
347func waitStarRocksReady(ctx context.Context, db *sql.DB) error {
348 ticker := time.NewTicker(3 * time.Second)
349 defer ticker.Stop()
350 timeout := time.After(10 * time.Minute)
351 for {
352 select {
353 case <-ticker.C:
354 if starRocksBackendAlive(ctx, db) {
355 return nil
356 }
357 case <-timeout:
358 return errors.Errorf("StarRocks backend did not become ready")
359 }
360 }
361}
362
363// starRocksBackendAlive reports whether SHOW BACKENDS lists a backend with Alive=true.
364func starRocksBackendAlive(ctx context.Context, db *sql.DB) bool {

Callers 1

GetStarRocksContainerFunction · 0.85

Calls 3

starRocksBackendAliveFunction · 0.85
StopMethod · 0.80
ErrorfMethod · 0.80

Tested by

no test coverage detected