DBaaS Fleet Telemetry: Distributed Pre-Flight Health Checks at Scale
Centralized polling architectures are an operational hazard at cloud scale; attempting to inspect thousands of databases via inbound SSH or SQL*Net connections turns your patch control plane into a self-inflicted denial-of-service attack.
TL;DR
- Problem: Fanning out inbound SSH or SQL*Net pre-flight checks across 10,000+ Oracle instances exhausts firewall
nf_conntracktables, centralizesSYSDBAcredentials, and acts on stale telemetry by the time a sweep finishes.- Answer: Move pre-flight evaluation to a cgroup-capped Go sidecar on each host that authenticates locally via Oracle Bequeath (
PROTOCOL=beq), pushes a low-cardinalityfleet_db_patch_readystate vector outbound, and gates Temporal patch waves with a fail-closed PromQLtimestamp()query.- Watch out:
godrorrejects"sys/ as sysdba"(use an explicit Bequeath descriptor orexternalAuth=1), PromQL staleness requirestimestamp(), and high-cardinality labels will still blow up the TSDB if you emit per-SQL dimensions.
Situation
Platform engineering teams operating Database-as-a-Service (DBaaS) fleets across hybrid and multi-cloud estates run continuous lifecycle workflows: quarterly Oracle Database Release Updates (RUs), Linux kernel patches, security baseline enforcement, and storage migrations across 5,000 to 20,000 database instances.
Before any destructive step—stopping an instance, switching $ORACLE_HOME, or running datapatch against the data dictionary—automated patch orchestrators enforce pre-flight health invariants. On Oracle Database 19c and 23ai, four checks separate a clean rolling patch from a stalled maintenance window:
- Dictionary Integrity: Zero unexpected
INVALIDobjects in core administrative schemas (SYS,SYSTEM,MDSYS,CTXSYS) inDBA_OBJECTS, and all components inDBA_REGISTRYreportingVALID. - Storage Capacity:
SYSTEM,SYSAUX, and activeUNDOtablespaces retain at least 25% free headroom inDBA_TABLESPACE_USAGE_METRICS(which accounts forAUTOEXTENDmax size in database blocks), and the Fast Recovery Area (V$RECOVERY_FILE_DEST) sits below 80% utilization to avoid archiver hangs (ORA-00257). - Replication Health: Physical standbys report transport and apply lag under 30 seconds in
V$DATAGUARD_STATSso emergency switchover remains viable if a primary fails to restart cleanly. - Workload Quiescence: No long-running uncommitted transactions (
V$TRANSACTION), active RMAN backups (V$RMAN_STATUS), or critical scheduler jobs (DBA_SCHEDULER_RUNNING_JOBS) are mid-flight beforeSHUTDOWN IMMEDIATE.
Historically, teams implemented these checks with centralized Ansible playbooks, Python Paramiko runners, or Jenkins pipelines opening inbound SSH and SQL*Net connections to every host in the fleet.
The Problem
Centralized pull polling breaks against four concrete scale, security, and concurrency constraints:
- Sweep latency creates decision drift (derived math): Suppose a centralized runner executes pre-flight checks with 50 concurrent workers, and each host requires 4 seconds for SSH/TLS handshake,
sqlplusor driver initialization, and dictionary queries. Across 10,000 databases, the minimum sweep time is(10,000 / 50) * 4s = 800 seconds(13.3 minutes) under zero-failure conditions—and if 10% of hosts hit a 30-second SSH timeout, those 1,000 timeouts alone add(1,000 / 50) * 30s = 600 seconds, pushing total sweep duration past 23 minutes. By the time wave execution starts, telemetry from the first hosts is already stale: a batch job that started 15 minutes into the sweep can fillUNDOor leave a massive uncommitted transaction open right beforeSHUTDOWN IMMEDIATE. - Stateful firewall
nf_conntrackexhaustion: Enterprise cloud firewalls and NAT gateways track every active TCP socket in kernelnf_conntracktables. Opening thousands of short-lived SSH and SQL*Net connections in parallel across VPCs consumes state-table entries that remain inTIME_WAITafter sockets close, riskingnf_conntrack: table full, dropping packetand dropping production application traffic alongside monitoring probes. - Centralized credential honeypot: A central polling engine requires
SYSDBApasswords, wallet passphrases, or SSH private keys for every database in the fleet. That runner becomes a high-value breach target, and routine corporate credential rotation frequently desynchronizes stored secrets, causing false-negative pre-flight failures. - TSDB cardinality explosion on naive push: Even if you switch to push metrics, emitting high-cardinality labels—such as SQL IDs, session IDs, or per-PDB object names—multiplies active series rapidly. Across 10,000 databases, emitting just 1,000 unique label combinations per host produces
10,000 * 1,000 = 10,000,000active time series, saturating Prometheus memory and slowing PromQL wave queries.
How do you evaluate real-time pre-flight health across 10,000+ Oracle instances in sub-second orchestration queries without opening inbound SSH/SQL*Net ports or storing fleet-wide SYSDBA credentials?
Options Considered
| Architecture | Inbound Ports Required | Credential Scope | Fleet Evaluation Latency | Why Chosen / Rejected |
|---|---|---|---|---|
| Centralized Ansible / Python Pull | SSH (22) + SQL*Net (1521/2484) | Global vault on central runner | Minutes to hours (worker-bound) | Rejected: Exhausts nf_conntrack, creates a central credential honeypot, and acts on stale state. |
| Regional Bastion Fanout | SSH / SQL*Net per VPC | Sharded per-region secrets | Minutes per region | Rejected: Reduces cross-VPC firewall pressure but still requires inbound ports and distributed credential management. |
| Local Sidecar + Central Prometheus Scrape | Inbound HTTP (9161) on every DB host | Local OS auth (no password) | Scrape interval (15–60s) | Rejected: Eliminates DB passwords, but central Prometheus still opens 10,000+ inbound TCP scrapes across private subnets. |
| Local Bequeath Sidecar + Outbound Push | None (0 inbound ports) | Local OS group (oinstall/dba) | Sub-second PromQL against TSDB | Chosen: Isolates credentials to local IPC, keeps DB subnets outbound-only, and decouples Temporal from host reachability. |
Running regional bastions is the most common intermediate step, because sharding workers into each VPC avoids traversing central transit firewalls. However, bastions do not eliminate inbound listener exposure or the operational burden of rotating SYSDBA secrets across every regional runner. Similarly, exposing a Prometheus /metrics endpoint on port 9161 solves database authentication via local OS auth, but still forces security teams to permit inbound scraping from central monitoring CIDRs into every restricted database subnet. Inverting the transport to outbound remote-write or Kafka push removes inbound firewall rules altogether.
The Distributed Sidecar Telemetry Architecture
The architecture separates telemetry collection, regional ingestion, and wave orchestration into three decoupled planes.
Plane 1: Local Bequeath Sidecar and Cgroup Sandbox
A compiled Go daemon runs on each database host under the local oracle OS user (oinstall / dba group). Instead of connecting through the TNS listener, it uses Oracle’s local Bequeath (PROTOCOL=beq) IPC mechanism, spawning a local server process with OS authentication and zero stored passwords.
A critical implementation detail for the godror Go driver: unlike sqlplus / as sysdba, godror (and underlying ODPI-C) cannot parse a bare "sys/ as sysdba" or "/ as sysdba" DSN. Local SYSDBA over Bequeath requires either externalAuth=1 (for externally identified accounts) or adminRole=SYSDBA paired with an explicit PROTOCOL=beq connect descriptor specifying PROGRAM, ORACLE_HOME, and ORACLE_SID.
package main
import (
"context"
"database/sql"
"fmt"
"log"
"os"
"time"
_ "github.com/godror/godror"
"github.com/prometheus/client_golang/prometheus"
)
var (
patchReadyGauge = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "fleet_db_patch_ready",
Help: "Binary indicator (1=Ready, 0=Blocked) of database patch readiness",
},
[]string{"region", "db_name", "role"},
)
invalidObjectsGauge = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "fleet_db_invalid_objects_total",
Help: "Invalid objects in SYS and SYSTEM schemas",
},
[]string{"region", "db_name"},
)
fraUsagePercentGauge = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "fleet_db_fra_usage_percent",
Help: "Fast Recovery Area utilization percentage",
},
[]string{"region", "db_name"},
)
)
func buildBequeathDSN(oracleHome, sid string) string {
desc := fmt.Sprintf(
`(DESCRIPTION=(ADDRESS=(PROTOCOL=beq)(PROGRAM=%s/bin/oracle)(ARGV0=oracle%s)`+
`(ENVS="ORACLE_HOME=%s,ORACLE_SID=%s")(ARGS="(DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))"))`+
`(CONNECT_DATA=(SID=%s)))`,
oracleHome, sid, oracleHome, sid, sid,
)
return fmt.Sprintf(`user="SYS" adminRole=SYSDBA connectString="%s"`, desc)
}
func collectTelemetry(db *sql.DB, region, dbName string) {
ctx, cancel := context.WithTimeout(context.Background(), 8*time.Second)
defer cancel()
query := `
SELECT
(SELECT COUNT(*) FROM dba_objects
WHERE status = 'INVALID' AND owner IN ('SYS', 'SYSTEM')) AS invalid_core_objs,
(SELECT NVL(ROUND((space_used / NULLIF(space_limit, 0)) * 100, 2), 0)
FROM v$recovery_file_dest) AS fra_pct,
(SELECT NVL(MAX(used_percent), 0) FROM dba_tablespace_usage_metrics
WHERE tablespace_name IN ('SYSTEM', 'SYSAUX')) AS sys_ts_pct,
(SELECT database_role FROM v$database) AS db_role,
(SELECT COUNT(*) FROM v$transaction) AS active_tx_count
FROM dual`
var invalidObjs, activeTx int
var fraPct, sysTsPct float64
var dbRole string
if err := db.QueryRowContext(ctx, query).Scan(&invalidObjs, &fraPct, &sysTsPct, &dbRole, &activeTx); err != nil {
log.Printf("[ERROR] Telemetry query failed: %v", err)
patchReadyGauge.WithLabelValues(region, dbName, "UNKNOWN").Set(0)
return
}
invalidObjectsGauge.WithLabelValues(region, dbName).Set(float64(invalidObjs))
fraUsagePercentGauge.WithLabelValues(region, dbName).Set(fraPct)
isReady := 1.0
if invalidObjs > 0 || fraPct >= 80.0 || sysTsPct >= 75.0 || activeTx > 0 {
isReady = 0.0
}
patchReadyGauge.WithLabelValues(region, dbName, dbRole).Set(isReady)
}
func main() {
dsn := buildBequeathDSN(os.Getenv("ORACLE_HOME"), os.Getenv("ORACLE_SID"))
db, err := sql.Open("godror", dsn)
if err != nil {
log.Fatalf("godror init failed: %v", err)
}
defer db.Close()
ticker := time.NewTicker(10 * time.Second)
defer ticker.Stop()
for range ticker.C {
collectTelemetry(db, os.Getenv("CLOUD_REGION"), os.Getenv("ORACLE_SID"))
}
}
Note the use of DBA_TABLESPACE_USAGE_METRICS (a native Oracle view that accounts for AUTOEXTEND max sizes in blocks) rather than the non-existent DBA_TABLESPACE_USAGE. To guarantee the collector never competes with Oracle foreground or LGWR/DBWR processes, systemd Cgroup v2 directives cap the daemon at 5% of one CPU core and 256 MB of RAM:
# /etc/systemd/system/db-telemetry-sidecar.service
[Service]
Type=simple
User=oracle
Group=oinstall
Environment=ORACLE_HOME=/u01/app/oracle/product/19.0.0.0/dbhome_1
Environment=ORACLE_SID=PRODDB01
ExecStart=/opt/enterprise/bin/db-telemetry-sidecar
Restart=always
RestartSec=5
CPUAccounting=true
CPUQuota=5%
MemoryAccounting=true
MemoryMax=256M
MemoryHigh=200M
Plane 2 & Plane 3: Outbound Ingestion and Fail-Closed Temporal Gate
The sidecar pushes its low-cardinality state vector (region, db_name, role—only 3 labels per instance) outbound over mTLS to a regional Kafka cluster or Prometheus remote-write gateway. Keeping label cardinality fixed at three keys is mandatory: if an engineer adds pdb_name, tablespace_name, or sql_id to the readiness gauge, series counts multiply across multi-tenant CDBs and blow through TSDB head-block memory budgets. Granular diagnostics—such as which specific tablespace crossed 75% or which SYS package became INVALID—belong in structured error logs or on-demand diagnostic events rather than high-frequency Prometheus labels.
To prevent thundering herds when a regional network partition heals or a Kafka broker rolls, each sidecar buffers at most the latest state vector in memory (dropping intermediate 10-second ticks rather than queuing unbounded backlogs) and reconnects using exponential backoff with full jitter (for example, sleep = random(0, min(cap, base * 2^attempt))). Dropping stale buffered ticks is intentional: for pre-flight gating, Temporal only cares about current database state, never replaying 30 minutes of historical 10-second gauges after a disconnect.
When Temporal schedules a patching wave, it evaluates readiness across the entire region with a single PromQL query that must wrap the metric in timestamp() to verify freshness:
# Fail-closed Temporal pre-flight gate:
# Only return PRIMARY instances whose latest sample is <= 60s old AND ready == 1
(
fleet_db_patch_ready{region="us-ashburn-1", role="PRIMARY"} == 1
)
and
(
(time() - timestamp(fleet_db_patch_ready{region="us-ashburn-1", role="PRIMARY"})) <= 60
)
Using time() - metric > 60 without timestamp() is a subtle PromQL bug: it subtracts the gauge value (0 or 1) from Unix epoch seconds rather than checking when the sample was scraped. Wrapping the series in timestamp() ensures that any dead sidecar, partitioned host, or OOM-killed agent drops out of the ready set within 60 seconds.
Telemetry Invariant Matrix
| Telemetry Metric | Underlying Oracle View | Ready Threshold | Failure Prevented |
|---|---|---|---|
| Core Invalid Objects | DBA_OBJECTS (SYS, SYSTEM) | 0 invalid objects | datapatch recompilation deadlocks or registry failures |
SYSTEM / SYSAUX Usage | DBA_TABLESPACE_USAGE_METRICS | < 75% of max autoextend | ORA-01653: unable to extend table mid-patch |
| Fast Recovery Area | V$RECOVERY_FILE_DEST | < 80% of SPACE_LIMIT | ORA-00257: archiver error during pre-patch backup |
| Data Guard Apply Lag | V$DATAGUARD_STATS | < 30 seconds | Unrecoverable switchover lag if primary reboot stalls |
| Active Transactions | V$TRANSACTION | 0 long-running txns | Prolonged SMON rollback recovery after SHUTDOWN |
How It Rolls Out
Replacing centralized pull scripts with a sidecar gate should happen in four stages so teams can verify telemetry parity before trusting the TSDB to authorize production restarts.
- Phase 1 — Shadow Deployment. Roll out
db-telemetry-sidecarunder systemd cgroup limits (CPUQuota=5%,MemoryMax=256M) across non-production and production hosts in read-only mode, keeping existing Ansible/Python pre-flight checks as the authoritative gate. Validation gate: ZeroORA-01031OS auth errors and zero cgroup OOM kills over 7 days. Rollback:systemctl stop db-telemetry-sidecar. - Phase 2 — Parity Audit. Run a shadow comparison job inside Temporal that queries both the legacy pull runner and the PromQL
timestamp()gate before non-production patch waves, logging every discrepancy. Validation gate: 100% agreement onSYSTEM/SYSAUXheadroom, FRA usage, and invalid core objects across a full patch cycle. Rollback: Keep legacy pull runner as the blocking gate. - Phase 3 — Canary Wave Gating. Switch Temporal’s pre-flight activity to enforce the PromQL gate on development and staging waves while keeping legacy scripts available as a manual fallback flag. Validation gate: Sub-second wave filtering and clean fail-closed exclusion when a test sidecar is intentionally stopped. Rollback: Flip the Temporal workflow feature flag back to pull mode.
- Phase 4 — Fleet Cutover and Credential Decommissioning. Enable PromQL gating for production waves, revoke central
SYSDBAsecrets from the legacy Ansible/Jenkins vault, and remove inbound SSH/SQL*Net rules used solely by the old polling servers.
In Practice
- Oracle
DBA_TABLESPACE_USAGE_METRICSbehavior (Oracle Database Reference): Unlike manual joins ofDBA_DATA_FILESandDBA_FREE_SPACE,DBA_TABLESPACE_USAGE_METRICScalculatesUSED_PERCENTagainstTABLESPACE_SIZEaccounting forAUTOEXTENDmax size in blocks—preventing false-positive alerts on auto-extensibleSYSTEM/SYSAUXdatafiles that appear 99% full at their current allocated size. - Data Guard standby-first invariant (
V$DATAGUARD_STATS): In an Oracle Data Guard topology, rolling Release Updates apply to physical standbys before the primary. CheckingV$DATAGUARD_STATSfor bothtransport lagandapply lagensures the standby is caught up beforeSHUTDOWN IMMEDIATEon the primary; if apply lag exceeds 30 seconds, the sidecar setsfleet_db_patch_ready = 0so Temporal pauses the wave rather than leaving the primary without a fast-failover target. - Oracle Bequeath (
PROTOCOL=beq) behavior (Oracle Net Services &godror): Because Bequeath spawns a local dedicated server process directly over OS pipes/IPC without traversingtnslsnr, telemetry continues working even if the TNS listener is down or firewalled, and OS group membership (oinstall/dba) replaces stored passwords. In containerized or multi-home environments, each sidecar instance must pointORACLE_HOMEandORACLE_SIDto the active GI/RDBMS home so out-of-place patching (rhpctlor Fleet Patching and Provisioning) updates the environment file alongside/etc/oratabduring home switchover. - OpenTelemetry Database Semantic Conventions (CNCF / OTel v1.30+): Teams standardizing beyond custom Prometheus gauges can map pool and operation telemetry to OpenTelemetry’s current database semantic conventions—
db.client.operation.duration(stable histogram, seconds) anddb.client.connection.count(replacing olderdb.client.connections.usage), tagged withdb.system.name—while keeping the discretefleet_db_patch_readystate vector for Temporal gating.
Where It Breaks
| Condition | Breaks How | Detect | Mitigate |
|---|---|---|---|
| Sidecar freezes on dictionary lock | DBA_OBJECTS waits on library cache lock during heavy DDL; stale 1 stays in TSDB | PromQL time() - timestamp(...) > 60 drops host from ready set | Wrap every query in context.WithTimeout(8*time.Second) and force patch_ready = 0 on error |
| Thundering herd after network partition | Thousands of sidecars reconnect to Kafka/remote-write simultaneously, exhausting broker memory | Surge in HTTP 429/503 or Kafka broker CPU/GC pauses | Implement exponential backoff with full jitter on sidecar push retries |
| Sidecar cgroup OOM kill | Unbounded log/metric buffer exceeds MemoryMax=256M; kernel kills agent | systemd restart counter increments and host disappears from TSDB | Set Restart=always, keep cardinality to 3 labels, and alert on missing heartbeats |
OS group drift removes dba membership | Sidecar Bequeath connection fails with ORA-01031: insufficient privileges | fleet_db_patch_ready flips to 0 across affected hosts | Enforce /etc/group membership via configuration management and alert on ORA-01031 |
| NTP clock skew on DB host | Host clock drifts > 120s; TSDB rejects remote-write samples as out-of-order | node_timex_offset_seconds > 0.5 alert fires | Gate patching on verified NTP sync alongside fleet_db_patch_ready |
| Non-critical schema invalid objects | An unused test schema invalid object blocks an entire canary wave if unfiltered | High false-positive patch_ready == 0 rate before maintenance window | Restrict DBA_OBJECTS invalid check strictly to SYS, SYSTEM, MDSYS, and CTXSYS |
Key Takeaways
- Inbound polling fails on physics and security before code quality matters: At 10,000 databases, even 50 concurrent workers hit multi-minute sweep drift, exhaust firewall
nf_conntrackstate tables, and force you to store fleet-wideSYSDBAcredentials in one place. godrorrequires an explicit Bequeath descriptor for local OS auth: Passing"sys/ as sysdba"fails ingodror; useadminRole=SYSDBAwith aPROTOCOL=beqconnectString(orexternalAuth=1) so the sidecar authenticates over local IPC with zero passwords.- Query
DBA_TABLESPACE_USAGE_METRICS, notDBA_TABLESPACE_USAGE: Oracle’s built-in view accounts forAUTOEXTENDceilings automatically, avoiding false pre-flight blocks onSYSTEMandSYSAUX. - PromQL freshness gates require
timestamp(): Always evaluate(time() - timestamp(fleet_db_patch_ready{...})) <= 60so a dead or OOM-killed sidecar fails closed rather than leaving a stale1in the TSDB. - Sandbox the collector with systemd Cgroup v2 limits:
CPUQuota=5%andMemoryMax=256Mguarantee a runaway telemetry query can never starve Oracle background processes.
What to Do Next
- Problem: Centralized SSH and SQL*Net polling cannot evaluate pre-flight health across thousands of Oracle databases without exhausting firewall state tables, centralizing
SYSDBAsecrets, and acting on stale data. - Solution: Deploy a cgroup-capped Go telemetry sidecar using local Bequeath (
PROTOCOL=beq) authentication, pushing low-cardinalityfleet_db_patch_readystate vectors outbound to a TSDB queried by Temporal with atimestamp()freshness guard. - Proof: Verify in shadow mode that every host emits fresh samples every 10 seconds with zero inbound firewall ports opened and 100% parity against legacy pre-flight checks.
- Action: Audit your current patch orchestrator this week for inbound SSH/SQL*Net fanout and central
SYSDBAvaults, then prototype thePROTOCOL=beqGo collector on a non-production Oracle 19c host.