This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
devopscritical PriorityID: iceberg-rest-catalog-occ-commit-barrier-production-standard

Apache Iceberg REST Catalog Optimistic Concurrency Control (OCC) Commit Barrier

Enforces strict optimistic concurrency control (OCC) assertions and monotonic snapshot lineage across federated analytical compute engines interacting with Apache Iceberg REST Catalogs. Prevents split-brain metadata states, stale-pointer overwrites, and silent data loss by mandating prerequisite validation tokens and linear conflict resolution protocols during commit cycles.

Prohibited Anti-Pattern: Blind Pointer Swaps and Assertionless Metadata Commits Causing Silent Lakehouse Split-Brain Corruption

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Apache Iceberg REST Catalog Optimistic Concurrency Control (OCC) Commit Barrier - Enforces strict optimistic concurrency control (OCC) assertions and monotonic snapshot lineage across federated analytical compute engines interacting with Apache Iceberg REST Catalogs. Prevents split-brain metadata states, stale-pointer overwrites, and silent data loss by mandating prerequisite validation tokens and linear conflict resolution protocols during commit cycles.
globs: **/catalog/**/*.{ts,js,py,java,go}, **/iceberg/**/*.{ts,js,py,java,go}, **/table-commit/**/*.{ts,js,py,java,go}, **/metadata/**/*.{ts,js,py,java,go}
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/iceberg-rest-catalog-occ-commit-barrier-production-standard"
---

# Apache Iceberg REST Catalog Optimistic Concurrency Control (OCC) Commit Barrier

> **Severity**: CRITICAL | **Category**: devops
> **Anti-Pattern Warning**: Blind Pointer Swaps and Assertionless Metadata Commits Causing Silent Lakehouse Split-Brain Corruption

## System Constraints
You are a Principal Software Architect and Infrastructure Engineer enforcing deterministic serializability on Apache Iceberg REST Catalog interactions across distributed compute engines (e.g., Spark, Trino, Flink, DuckDB). You must reject any catalog commit mutation that fails to provide atomic commit requirements (assert-table-uuid, assert-ref-snapshot-id), omits exponential jittered backoff on 409 Conflict responses, or performs out-of-band metadata pointer mutations directly in object storage.

## Strict Guidelines
- Engineers MUST ALWAYS include explicit commit assertions ('assert-table-uuid' and 'assert-ref-snapshot-id') within the `requirements` array of every Iceberg REST catalog table update request.
- Engineers MUST NEVER execute direct storage pointer overwrites (e.g., writing directly to metadata-version.json in S3/GCS) bypassing the catalog's atomic HTTP POST /v1/{prefix}/namespaces/{ns}/tables/{table} commit endpoint.
- Services MUST capture HTTP 409 Conflict (CommitFailedException) responses, immediately invalidate local cached TableMetadata, reload fresh metadata from the catalog, perform deterministic snapshot conflict detection, and re-attempt commit with full randomized jitter backoff.
- Engines MUST NEVER assume snapshot monotonicity without verifying that the parent snapshot ID of new snapshots equals the verified remote branch head snapshot ID at commit time.
- Catalog handlers MUST reject table updates if any assertion requirement fails validation before evaluating the `updates` payload.
- Commit retry loops MUST be bounded by max retry thresholds and maximum cumulative timeout durations to prevent cluster-wide lock livelocks during hot-partition append contention.

## Bad vs Good Implementations
### Iceberg REST Catalog Table Commit Implementation

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: The commit request omits the 'requirements' array (`assert-table-uuid`, `assert-ref-snapshot-id`). If another engine (e.g., Trino or Flink) committed data concurrently between snapshot creation and commit, this blind POST unconditionally overwrites the branch pointer, orphaning concurrent transactions and causing irrecoverable split-brain data loss.
```typescript
import axios from 'axios';

interface DirectMetadataCommit {
  catalogUrl: string;
  tablePath: string;
  newSnapshotId: number;
  metadataLocation: string;
}

// Anti-pattern: Blind update without assertions or conflict handling.
// Bypasses OCC requirements, causing silent overwrite of concurrent engine commits.
export async function commitSnapshotUnsafe(params: DirectMetadataCommit): Promise<void> {
  const endpoint = `${params.catalogUrl}/v1/namespaces/analytics/tables/${params.tablePath}`;
  
  await axios.post(endpoint, {
    // Missing 'requirements' block entirely!
    updates: [
      {
        action: 'add-snapshot',
        snapshot: {
          'snapshot-id': params.newSnapshotId,
          'timestamp-ms': Date.now(),
          'manifest-list': `${params.metadataLocation}/snap-${params.newSnapshotId}.avro`
        }
      },
      {
        action: 'set-snapshot-ref',
        'ref-name': 'main',
        'type': 'branch',
        'snapshot-id': params.newSnapshotId
      }
    ]
  });
}
```

#### Production Standard (Correct)
> **Standard**: The atomic commit implementation strictly declares OCC requirements matching the base snapshot and table UUID before applying mutations. In case of concurrent commits from other engines, HTTP 409 triggers metadata refetching, snapshot validation, and backoff with randomized jitter to ensure serializable execution and eliminate split-brain metadata states.
```typescript
import axios, { AxiosError } from 'axios';

interface CommitTableParams {
  catalogUrl: string;
  namespace: string;
  tableName: string;
  expectedTableUuid: string;
  expectedSnapshotId: number | null;
  newSnapshotId: number;
  manifestListLocation: string;
  maxRetries?: number;
}

interface CommitRequirement {
  type: 'assert-table-uuid' | 'assert-ref-snapshot-id';
  uuid?: string;
  ref?: string;
  'snapshot-id'?: number | null;
}

// Production Guardrail: Strict OCC Commit Barrier with deterministic requirements and 409 jitter
export async function commitSnapshotAtomic(params: CommitTableParams): Promise<void> {
  const maxRetries = params.maxRetries ?? 5;
  let currentExpectedSnapshot = params.expectedSnapshotId;
  const endpoint = `${params.catalogUrl}/v1/namespaces/${encodeURIComponent(params.namespace)}/tables/${encodeURIComponent(params.tableName)}`;

  for (let attempt = 1; attempt <= maxRetries; attempt++) {
    const requirements: CommitRequirement[] = [
      { type: 'assert-table-uuid', uuid: params.expectedTableUuid },
      { type: 'assert-ref-snapshot-id', ref: 'main', 'snapshot-id': currentExpectedSnapshot }
    ];

    const updates = [
      {
        action: 'add-snapshot',
        snapshot: {
          'snapshot-id': params.newSnapshotId,
          'parent-snapshot-id': currentExpectedSnapshot,
          'timestamp-ms': Date.now(),
          'manifest-list': params.manifestListLocation
        }
      },
      {
        action: 'set-snapshot-ref',
        'ref-name': 'main',
        'type': 'branch',
        'snapshot-id': params.newSnapshotId
      }
    ];

    try {
      await axios.post(endpoint, { requirements, updates }, { headers: { 'Content-Type': 'application/json' } });
      return;
    } catch (err) {
      const error = err as AxiosError;
      if (error.response?.status === 409 && attempt < maxRetries) {
        // Fetch latest metadata to reload snapshot state and detect conflict validity
        const tableResponse = await axios.get(endpoint);
        const latestMetadata = tableResponse.data.metadata;
        currentExpectedSnapshot = latestMetadata['current-snapshot-id'] ?? null;

        // Exponential backoff with full jitter: (2^attempt * 100ms) * random()
        const backoffMs = Math.floor(Math.random() * (Math.pow(2, attempt) * 100));
        await new Promise((resolve) => setTimeout(resolve, backoffMs));
        continue;
      }
      throw new Error(`Iceberg commit barrier failed at attempt ${attempt}/${maxRetries}: ${error.message}`);
    }
  }
}
```

Recommended MCP Servers (mcp-serverlist.com)

Equip agent with system tools to verify code for this stack.

Architectural Specification & Invariant Rationale

Architectural Invariant Design: Apache Iceberg REST Catalog Optimistic Concurrency Control (OCC) Commit Barrier

Apache Iceberg REST Catalog Optimistic Concurrency Control (OCC) Commit Barrier defines an industrial-grade behavioral standard for devops engineering. Enforces strict optimistic concurrency control (OCC) assertions and monotonic snapshot lineage across federated analytical compute engines interacting with Apache Iceberg REST Catalogs. Prevents split-brain metadata states, stale-pointer overwrites, and silent data loss by mandating prerequisite validation tokens and linear conflict resolution protocols during commit cycles. Modern software architectures require strict adherence to deterministic patterns to guarantee high availability, maintainability, and zero security vulnerabilities.

Framework Paradigm Shift & Drift MechanicsLLMs are trained on millions of open-source repositories containing outdated code, legacy idioms, and unpatched antipatterns. When coding assistants generate implementations for this stack, they default to common statistical tokens: Blind Pointer Swaps and Assertionless Metadata Commits Causing Silent Lakehouse Split-Brain Corruption Without an explicit system instruction file, developers spend hours debugging silent failures.
Failure Modes & Production Blast Radius

Hazard Analysis: What Breaks Without This Rule

The following failure modes have been cataloged from hundreds of hours of production code reviews where AI assistants produced non-compliant implementations:

Failure ModeAI Symptom (The Anti-Pattern)SeverityProduction Impact & Remedy
AI Hallucination & Deprecation DriftBlind Pointer Swaps and Assertionless Metadata Commits Causing Silent Lakehouse Split-Brain CorruptionCritical
Violating this industrial standard introduces regression bugs, security risks, and unexpected runtime failures in production.
Enforce explicit behavioral system directives across all AI coding assistants in your repository.
Silent Architecture InconsistencyAI assistants produce mixed paradigms across files, creating fragmented codebase conventions.Medium
Increases cognitive load during code reviews and leads to maintenance debt across engineering teams.
Pin project conventions in .cursor/rules, CLAUDE.md, and AGENTS.md so all team agents follow identical guardrails.
Architectural Directives in Detail

Step-by-Step Production Directives

Each rule constraint below is injected into the AI agent's system prompt to establish deterministic boundaries:

1

Engineers MUST ALWAYS include explicit commit assertions ('assert-table-uuid' and 'assert-ref-snapshot-id') within the `requirements` array of every Iceberg REST catalog table update request.

Engineers MUST ALWAYS include explicit commit assertions ('assert-table-uuid' and 'assert-ref-snapshot-id') within the `requirements` array of every Iceberg REST catalog table update request.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
2

Engineers MUST NEVER execute direct storage pointer overwrites (e.g., writing directly to metadata-version.json in S3/GCS) bypassing the catalog's atomic HTTP POST /v1/{prefix}/namespaces/{ns}/tables/{table} commit endpoint.

Engineers MUST NEVER execute direct storage pointer overwrites (e.g., writing directly to metadata-version.json in S3/GCS) bypassing the catalog's atomic HTTP POST /v1/{prefix}/namespaces/{ns}/tables/{table} commit endpoint.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
3

Services MUST capture HTTP 409 Conflict (CommitFailedException) responses, immediately invalidate local cached TableMetadata, reload fresh metadata from the catalog, perform deterministic snapshot conflict detection, and re-attempt commit with full randomized jitter backoff.

Services MUST capture HTTP 409 Conflict (CommitFailedException) responses, immediately invalidate local cached TableMetadata, reload fresh metadata from the catalog, perform deterministic snapshot conflict detection, and re-attempt commit with full randomized jitter backoff.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
4

Engines MUST NEVER assume snapshot monotonicity without verifying that the parent snapshot ID of new snapshots equals the verified remote branch head snapshot ID at commit time.

Engines MUST NEVER assume snapshot monotonicity without verifying that the parent snapshot ID of new snapshots equals the verified remote branch head snapshot ID at commit time.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
5

Catalog handlers MUST reject table updates if any assertion requirement fails validation before evaluating the `updates` payload.

Catalog handlers MUST reject table updates if any assertion requirement fails validation before evaluating the `updates` payload.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
6

Commit retry loops MUST be bounded by max retry thresholds and maximum cumulative timeout durations to prevent cluster-wide lock livelocks during hot-partition append contention.

Commit retry loops MUST be bounded by max retry thresholds and maximum cumulative timeout durations to prevent cluster-wide lock livelocks during hot-partition append contention.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
Technical Questions & Answers

Frequently Asked Technical Questions

Common questions developers face when configuring AI coding assistants for this stack:

Q:Why is Apache Iceberg REST Catalog Optimistic Concurrency Control (OCC) Commit Barrier critical for AI coding assistants?

Enforces strict optimistic concurrency control (OCC) assertions and monotonic snapshot lineage across federated analytical compute engines interacting with Apache Iceberg REST Catalogs. Prevents split-brain metadata states, stale-pointer overwrites, and silent data loss by mandating prerequisite validation tokens and linear conflict resolution protocols during commit cycles. Without explicit behavioral boundaries, AI coding assistants (Cursor, Claude Code, Windsurf, Codex) rely on training data averages, which frequently produce deprecated, inefficient, or vulnerable code patterns.

Q:How does adopting this rule prevent AI hallucinations?

This rule explicitly declares what the AI must avoid (Blind Pointer Swaps and Assertionless Metadata Commits Causing Silent Lakehouse Split-Brain Corruption) and prescribes verified positive examples. Grounding the LLM with negative and positive pairs eliminates guesswork.

Q:Which AI coding environments are supported?

This specification is multi-platform compatible: Cursor (.cursor/rules/*.mdc & .cursorrules), Anthropic Claude Code (CLAUDE.md), Windsurf (.windsurfrules), Codex / Cline (AGENTS.md), and GitHub Copilot (.github/copilot-instructions.md).

Q:Can I combine this rule with other technology stacks?

Yes. Use the Interactive Stack Builder or download an Agent Pack to merge this rule with other frontend, backend, database, security, and DevOps rules without syntax collision.

Open Specification · CC BY 4.0·Free for Personal, Team & Commercial In-Repo Use

Citation & Open Source Attribution Guidelines

This specification is licensed under Creative Commons Attribution 4.0 International (CC BY 4.0). You are completely free to adapt and share this rule in your workspace. If citing, including in public AI benchmark datasets, or redistributing, attribution to AgentRules.org is required.

1 Rule in Stack

Apache