Skip to content

Multi-table commit does not isolate requirements on tables without updates: concurrent transactions both succeed #5807

Open

Description

@JeonDaehong

Describe the bug

POST /api/catalog/v1/{prefix}/transactions/commit does not isolate requirements on tables that the transaction does not update: two concurrent multi-table commits that each change one table and assert (with a requirement-only table change, updates: []) that the other table is unchanged both succeed.

To Reproduce

  1. Start Polaris 1.7.0 (apache/polaris:1.7.0, default in-memory persistence) with a FILE catalog repro and a principal that can manage its content.
  2. Run the script below: python skew_repro.py http://localhost:8181/api/catalog repro <token>
"""Two concurrent multi-table commits, each changing one table and asserting the other is
unchanged. A serializable catalog commits at most one of them per round.

python skew_repro.py http://localhost:8181 [prefix] [bearer-token]
"""
import json, sys, threading, urllib.request, urllib.error

base = sys.argv[1].rstrip("/") + "/v1/" + (sys.argv[2] + "/" if len(sys.argv) > 2 and sys.argv[2] else "")
token = sys.argv[3] if len(sys.argv) > 3 else None

def call(method, path, body=None):
    req = urllib.request.Request(base + path, method=method,
                                 data=json.dumps(body).encode() if body is not None else None,
                                 headers={"Content-Type": "application/json",
                                          **({"Authorization": f"Bearer {token}"} if token else {})})
    try:
        with urllib.request.urlopen(req) as r:
            return r.status, (json.loads(r.read() or b"null"))
    except urllib.error.HTTPError as e:
        return e.code, e.read().decode()

schema = {"type": "struct", "fields": [{"id": 1, "name": "id", "required": True, "type": "long"}]}
call("POST", "namespaces", {"namespace": ["skew"]})
for t in ("a", "b"):
    call("DELETE", f"namespaces/skew/tables/{t}")
    call("POST", "namespaces/skew/tables", {"name": t, "schema": schema, "stage-create": False})

def meta(t):
    return call("GET", f"namespaces/skew/tables/{t}")[1]["metadata"]

def change(t, other, other_schema_id, n):
    m = meta(t)
    return {"identifier": {"namespace": ["skew"], "name": t},
            "requirements": [{"type": "assert-current-schema-id", "current-schema-id": m["current-schema-id"]}],
            "updates": [{"action": "add-schema", "last-column-id": 100 + n, "schema": {"type": "struct", "fields": [
                            {"id": 1, "name": "id", "required": True, "type": "long"},
                            {"id": 100 + n, "name": f"c{n}", "required": False, "type": "long"}]}},
                        {"action": "set-current-schema", "schema-id": -1}]}, {
            "identifier": {"namespace": ["skew"], "name": other},
            "requirements": [{"type": "assert-current-schema-id", "current-schema-id": other_schema_id}],
            "updates": []}

both = 0
codes = {}
for n in range(1, 31):
    a, b = meta("a")["current-schema-id"], meta("b")["current-schema-id"]
    bodies = [{"table-changes": list(change("a", "b", b, 2 * n))},
              {"table-changes": list(change("b", "a", a, 2 * n + 1))}]
    status = [None, None]
    barrier = threading.Barrier(2)
    def run(i):
        barrier.wait()
        status[i] = call("POST", "transactions/commit", bodies[i])[0]
    threads = [threading.Thread(target=run, args=(i,)) for i in (0, 1)]
    [t.start() for t in threads]
    [t.join() for t in threads]
    both += all(s in (200, 204) for s in status)
    for s in status:
        codes[s] = codes.get(s, 0) + 1
print(f"both transactions committed in {both} of 30 rounds; status codes {codes}")

Actual Behavior

both transactions committed in 24 of 30 rounds; status codes {204: 54, 409: 6}

(20 to 29 of 30 rounds over three runs.)

Each round, T1 changes the current schema of a and asserts assert-current-schema-id on b; T2 does the reverse. Both commit, although each invalidates the other's assertion.

Expected Behavior

At most one of the two transactions commits per round (the other fails with 409 CommitFailedException): a requirement on a table in a multi-table commit should hold when the transaction commits, also for tables the transaction does not update. Lakekeeper 0.13.6 and Nessie 0.108.8 reject one of them in every round.

Additional context

Use case: a service that validates a write against several tables (e.g. foreign keys between them) asserts that the tables it read are unchanged, so that the catalog arbitrates concurrent writers. Without isolation, a child insert validated against a parent key and a delete of that parent key can both commit.

The Iceberg REST fixture shows the same behaviour (29 of 30); reported to apache/iceberg as well: apache/iceberg#18552. Found while testing Open Integrity Plane; the fuller probe is compat/multitable_probe.py there. Related: #766, #1202.

System information

Polaris 1.7.0 (apache/polaris:1.7.0 container), in-memory persistence, FILE storage; Ubuntu 24.04 host.

Activity

  1. aiskakov28 commented on Oct 28, 2026

    @aiskakov28

    Confirming this on Polaris 1.8.0 (apache/polaris:1.8.0) with relational-jdbc persistence on Postgres 17, so it isn't limited to 1.7.0 or in-memory persistence.

    Setup: an S3 catalog (S3-compatible local storage), two fresh tables per round. Each transaction changes one table (add-schema + set-current-schema) and sends a requirement-only change for the other (assert-table-uuid + assert-current-schema-id: 0, updates: []). The two transactions are sent concurrently.

    Result: both transactions returned 204 in 10 of 10 rounds, on two separate runs, and the final loads show both tables at schema 1. The same requirement sent sequentially, after the other table has already changed, is rejected with 409. So the requirement itself is validated; only the concurrent case gets through.

    This matches the analysis in #5820: in IcebergCatalogHandler.commitTransaction, a table whose currentMetadata.changes() is empty never reaches tableOps.commit, so it never joins pendingUpdates, and updateEntitiesPropertiesIfNotChanged doesn't check its version.

  2. added a commit that references this issue on Nov 3, 2026
    f9d7f1c
  3. added 4 commits that reference this issue on Nov 12, 2026
    fc23f9a
    edd2926
    14f34c7
    28224c0
  4. github-actions commented on Nov 28, 2026

    @github-actions

    This issue is stale because it has been open 30 days with no activity. Remove stale label or comment if you think it's still relevant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions