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_conntrack tables, centralizes SYSDBA credentials, 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-cardinality fleet_db_patch_ready state vector outbound, and gates Temporal patch waves with a fail-closed PromQL timestamp() query.
  • Watch out: godror rejects "sys/ as sysdba" (use an explicit Bequeath descriptor or externalAuth=1), PromQL staleness requires timestamp(), and high-cardinality labels will still blow up the TSDB if you emit per-SQL dimensions.

Push-based pre-flight telemetry pipeline from local Bequeath IPC to Temporal gate

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:

  1. Dictionary Integrity: Zero unexpected INVALID objects in core administrative schemas (SYS, SYSTEM, MDSYS, CTXSYS) in DBA_OBJECTS, and all components in DBA_REGISTRY reporting VALID.
  2. Storage Capacity: SYSTEM, SYSAUX, and active UNDO tablespaces retain at least 25% free headroom in DBA_TABLESPACE_USAGE_METRICS (which accounts for AUTOEXTEND max size in database blocks), and the Fast Recovery Area (V$RECOVERY_FILE_DEST) sits below 80% utilization to avoid archiver hangs (ORA-00257).
  3. Replication Health: Physical standbys report transport and apply lag under 30 seconds in V$DATAGUARD_STATS so emergency switchover remains viable if a primary fails to restart cleanly.
  4. 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 before SHUTDOWN 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:

  1. 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, sqlplus or 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 fill UNDO or leave a massive uncommitted transaction open right before SHUTDOWN IMMEDIATE.
  2. Stateful firewall nf_conntrack exhaustion: Enterprise cloud firewalls and NAT gateways track every active TCP socket in kernel nf_conntrack tables. Opening thousands of short-lived SSH and SQL*Net connections in parallel across VPCs consumes state-table entries that remain in TIME_WAIT after sockets close, risking nf_conntrack: table full, dropping packet and dropping production application traffic alongside monitoring probes.
  3. Centralized credential honeypot: A central polling engine requires SYSDBA passwords, 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.
  4. 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,000 active time series, saturating Prometheus memory and slowing PromQL wave queries.

Four scaling limits that break centralized SSH and SQL polling

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

ArchitectureInbound Ports RequiredCredential ScopeFleet Evaluation LatencyWhy Chosen / Rejected
Centralized Ansible / Python PullSSH (22) + SQL*Net (1521/2484)Global vault on central runnerMinutes to hours (worker-bound)Rejected: Exhausts nf_conntrack, creates a central credential honeypot, and acts on stale state.
Regional Bastion FanoutSSH / SQL*Net per VPCSharded per-region secretsMinutes per regionRejected: Reduces cross-VPC firewall pressure but still requires inbound ports and distributed credential management.
Local Sidecar + Central Prometheus ScrapeInbound HTTP (9161) on every DB hostLocal 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 PushNone (0 inbound ports)Local OS group (oinstall/dba)Sub-second PromQL against TSDBChosen: Isolates credentials to local IPC, keeps DB subnets outbound-only, and decouples Temporal from host reachability.

Comparison of four fleet pre-flight architectures

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.

Three decoupled planes separating collection, ingestion, and gating

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 MetricUnderlying Oracle ViewReady ThresholdFailure Prevented
Core Invalid ObjectsDBA_OBJECTS (SYS, SYSTEM)0 invalid objectsdatapatch recompilation deadlocks or registry failures
SYSTEM / SYSAUX UsageDBA_TABLESPACE_USAGE_METRICS< 75% of max autoextendORA-01653: unable to extend table mid-patch
Fast Recovery AreaV$RECOVERY_FILE_DEST< 80% of SPACE_LIMITORA-00257: archiver error during pre-patch backup
Data Guard Apply LagV$DATAGUARD_STATS< 30 secondsUnrecoverable switchover lag if primary reboot stalls
Active TransactionsV$TRANSACTION0 long-running txnsProlonged 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.

Four-phase shadow-mode rollout with parity audit and canary gating

  1. Phase 1 — Shadow Deployment. Roll out db-telemetry-sidecar under 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: Zero ORA-01031 OS auth errors and zero cgroup OOM kills over 7 days. Rollback: systemctl stop db-telemetry-sidecar.
  2. 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 on SYSTEM/SYSAUX headroom, FRA usage, and invalid core objects across a full patch cycle. Rollback: Keep legacy pull runner as the blocking gate.
  3. 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.
  4. Phase 4 — Fleet Cutover and Credential Decommissioning. Enable PromQL gating for production waves, revoke central SYSDBA secrets 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_METRICS behavior (Oracle Database Reference): Unlike manual joins of DBA_DATA_FILES and DBA_FREE_SPACE, DBA_TABLESPACE_USAGE_METRICS calculates USED_PERCENT against TABLESPACE_SIZE accounting for AUTOEXTEND max size in blocks—preventing false-positive alerts on auto-extensible SYSTEM/SYSAUX datafiles 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. Checking V$DATAGUARD_STATS for both transport lag and apply lag ensures the standby is caught up before SHUTDOWN IMMEDIATE on the primary; if apply lag exceeds 30 seconds, the sidecar sets fleet_db_patch_ready = 0 so 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 traversing tnslsnr, 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 point ORACLE_HOME and ORACLE_SID to the active GI/RDBMS home so out-of-place patching (rhpctl or Fleet Patching and Provisioning) updates the environment file alongside /etc/oratab during 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) and db.client.connection.count (replacing older db.client.connections.usage), tagged with db.system.name—while keeping the discrete fleet_db_patch_ready state vector for Temporal gating.

Where It Breaks

ConditionBreaks HowDetectMitigate
Sidecar freezes on dictionary lockDBA_OBJECTS waits on library cache lock during heavy DDL; stale 1 stays in TSDBPromQL time() - timestamp(...) > 60 drops host from ready setWrap every query in context.WithTimeout(8*time.Second) and force patch_ready = 0 on error
Thundering herd after network partitionThousands of sidecars reconnect to Kafka/remote-write simultaneously, exhausting broker memorySurge in HTTP 429/503 or Kafka broker CPU/GC pausesImplement exponential backoff with full jitter on sidecar push retries
Sidecar cgroup OOM killUnbounded log/metric buffer exceeds MemoryMax=256M; kernel kills agentsystemd restart counter increments and host disappears from TSDBSet Restart=always, keep cardinality to 3 labels, and alert on missing heartbeats
OS group drift removes dba membershipSidecar Bequeath connection fails with ORA-01031: insufficient privilegesfleet_db_patch_ready flips to 0 across affected hostsEnforce /etc/group membership via configuration management and alert on ORA-01031
NTP clock skew on DB hostHost clock drifts > 120s; TSDB rejects remote-write samples as out-of-ordernode_timex_offset_seconds > 0.5 alert firesGate patching on verified NTP sync alongside fleet_db_patch_ready
Non-critical schema invalid objectsAn unused test schema invalid object blocks an entire canary wave if unfilteredHigh false-positive patch_ready == 0 rate before maintenance windowRestrict DBA_OBJECTS invalid check strictly to SYS, SYSTEM, MDSYS, and CTXSYS

Four silent failure modes in push-based fleet telemetry

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_conntrack state tables, and force you to store fleet-wide SYSDBA credentials in one place.
  • godror requires an explicit Bequeath descriptor for local OS auth: Passing "sys/ as sysdba" fails in godror; use adminRole=SYSDBA with a PROTOCOL=beq connectString (or externalAuth=1) so the sidecar authenticates over local IPC with zero passwords.
  • Query DBA_TABLESPACE_USAGE_METRICS, not DBA_TABLESPACE_USAGE: Oracle’s built-in view accounts for AUTOEXTEND ceilings automatically, avoiding false pre-flight blocks on SYSTEM and SYSAUX.
  • PromQL freshness gates require timestamp(): Always evaluate (time() - timestamp(fleet_db_patch_ready{...})) <= 60 so a dead or OOM-killed sidecar fails closed rather than leaving a stale 1 in the TSDB.
  • Sandbox the collector with systemd Cgroup v2 limits: CPUQuota=5% and MemoryMax=256M guarantee 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 SYSDBA secrets, and acting on stale data.
  • Solution: Deploy a cgroup-capped Go telemetry sidecar using local Bequeath (PROTOCOL=beq) authentication, pushing low-cardinality fleet_db_patch_ready state vectors outbound to a TSDB queried by Temporal with a timestamp() 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 SYSDBA vaults, then prototype the PROTOCOL=beq Go collector on a non-production Oracle 19c host.