Skip to content

[python] Avoid redundant latest snapshot hint probes - #11662

Open
YannByron wants to merge 1 commit into
apache:masterfrom
YannByron:codex/python-direct-latest-hint
Open

YannByron wants to merge 1 commit into
apache:masterfrom
YannByron:codex/python-direct-latest-hint

Conversation

@YannByron

Copy link
Copy Markdown
Contributor

Purpose

A filesystem snapshot lookup currently probes the snapshot directory and LATEST before reading the hint, even though opening the hint already reports a missing object. Read LATEST directly and reconcile an empty, stale, or corrupt hint with the snapshot listing. When the hint is missing, retain the directory existence check so an absent directory still returns an empty table without requiring unsupported directory listing on legacy OSS/PyArrow < 16.

Keep the current and next snapshot existence checks. Cached snapshot bytes must not revive a snapshot deleted by another process. A hint or listing permission/service error must not be treated as proof of an empty table; the existing recovery from an unreadable hint through a readable snapshot listing is preserved. Catalog-provided snapshot loaders are unchanged.

Tests

  • RED: a valid-hint regression observes four FileIO.exists calls on the base revision (directory, hint, current snapshot, next snapshot); after the change it observes only the two snapshot checks, with identical snapshot contents and no listing.
  • Cover commits with a stale hint, missing/empty/corrupt hints, a missing snapshot directory, unreadable hints, probe/listing errors, and remote expiration of a cached snapshot.
  • Cache-safety mutation: removing the current-snapshot existence check makes the expiration regression fail (RuntimeError not raised).
  • Snapshot manager, time travel, cache, schema, and branch suites: 171 passed.
  • Legacy OSS regression: a missing hint and directory must not invoke unsupported listing. Directory probe permission/time-out errors still propagate. Both added cases fail before retaining this missing-hint-only probe, then pass afterward.
  • Filesystem catalog suite, including immutable-option guards: 24 passed.
  • Repository-configured flake8 and git diff --check: passed.
  • Additional local HTTP fixture check with the actual PyArrow 19.0.1 S3 client: HTTP 404 is FileNotFoundError and an empty listing produces None; HTTP 403 is an OSError and an empty listing still raises, preserving the fail-closed behavior. This does not require cloud credentials and is not a live OSS benchmark.

The call-count regression measures SnapshotManager-level probes, not a guaranteed HTTP request count for every backend. No new end-to-end speedup is claimed. No API, configuration, or storage-format changes.

Read LATEST directly while retaining snapshot existence checks and listing
reconciliation. Check the directory only when the hint is missing, retaining
the empty-table path for legacy OSS without directory listing support.
Keep unreadable hints distinct from genuinely empty tables and reject
remotely expired snapshots even when their bytes remain cached.

Co-Authored-By: Codex <noreply@anthropic.com>
AI-Model: gpt-6
AI-Contributed/Feature: 45/45
AI-Contributed/UT: 156/156
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant