paimon icon indicating copy to clipboard operation
paimon copied to clipboard

[Bug] PyPaimon reports success when a filesystem tag or branch rename fails

Open skyyyy955 opened this issue 2 weeks ago • 2 comments

Search before asking

  • [x] I checked existing reports. #11281 and #11282 cover the Java implementation. I can reproduce the same behavior through the Python filesystem catalog.

Paimon version

2.2-SNAPSHOT, 7a30ef580e8d78b3130ba944fce4530b335f5724

Compute Engine

PyPaimon on Windows, Python 3.10.11, PyArrow 19.0.1, local filesystem and Parquet.

Minimal reproduce step

Start with a fresh Parquet append table that has one committed snapshot (ID 1). Set warehouse to the catalog's warehouse directory and name to the table's full name. The example uses two independent clients. The barrier just starts the two public API calls together.

from concurrent.futures import ThreadPoolExecutor
from threading import Barrier

from pypaimon import CatalogFactory

def client():
    return CatalogFactory.create({"warehouse": warehouse})

for kind in ("branch", "tag"):
    owner = client()
    if kind == "branch":
        owner.create_branch(name, "old")
    else:
        owner.get_table(name).create_tag("old", snapshot_id=1)

    clients = [client(), client()]
    targets = ["new_a", "new_b"]
    start = Barrier(2)

    def rename(i):
        start.wait(timeout=15)
        try:
            getattr(clients[i], "rename_" + kind)(name, "old", targets[i])
            return "ok"
        except Exception as error:
            return type(error).__name__

    with ThreadPoolExecutor(max_workers=2) as pool:
        results = list(pool.map(rename, (0, 1)))

    fresh = client()
    names = fresh.list_branches(name) if kind == "branch" else fresh.get_table(name).list_tags()
    print(kind, results, sorted(set(targets) & set(names)))

What doesn't meet your expectations?

Both callers returned ok, but the old name was gone and only one of the two target names existed. A caller can therefore be told that a rename succeeded and then fail to find its branch or tag under the new name.

With fresh names each time, I saw this in 12/12 branch trials and 12/12 tag trials. A single-client rename produced the expected target in both cases. In the concurrent case, only the caller whose rename took effect should report success.

Anything else?

Both clients can pass the existence checks before either moves the file. When the first move wins, LocalFileIO.rename() can return False to the second caller. Both Python managers currently discard that return value. Branch rename · Tag rename · LocalFileIO.rename

Are you willing to submit a PR?

  • [x] I'm willing to submit a PR.

Could you assign this to me? I'd like to check the rename result in both managers, include the source and target names in the error, and add tests that verify the persisted names after failure and retry.

skyyyy955 avatar Nov 20 '26 09:11 skyyyy955

I have a local patch for both branch and tag renames. I verified that it reports the failure and that the rename can be retried successfully. All 105 related tests passed locally. Could you assign this issue to me? Thanks!

skyyyy955 avatar Nov 23 '26 01:11 skyyyy955

Hi @JingsongLi, could you assign this one to me? I’ve put the Python fix and tests on my fork. It covers the same case as #11282, where two callers can both see success even though only one rename went through. Thanks!

skyyyy955 avatar Nov 27 '26 07:11 skyyyy955