Nandor Kollar has posted comments on this change. ( 
http://gerrit.cloudera.org:8080/24838 )

Change subject: IMPALA-15145: Propagate credential metadata to Scan Nodes / 
Execution Plan
......................................................................


Patch Set 9:

(2 comments)

http://gerrit.cloudera.org:8080/#/c/24838/9/be/src/exec/hdfs-scan-node-base.cc
File be/src/exec/hdfs-scan-node-base.cc:

http://gerrit.cloudera.org:8080/#/c/24838/9/be/src/exec/hdfs-scan-node-base.cc@253
PS9, Line 253:   // connections opened below (and by other operators of this 
query) can use them.
This only holds for operators on the same backend that run after this scan. 
This is the only place that registers vended credentials (line 256), and 
QueryCredentials lives on the
  per-backend QueryState. So a backend that doesn't scan the table has no 
credentials and silently falls back to S3ConnCredentials / core-site:
  - INSERT INTO rest_tbl VALUES (...) or INSERT ... SELECT FROM other_tbl: 
nothing scans the target, so the sink's GetConnection calls in 
TableSinkBase::InitOutputPartition
    (table-sink-base.cc:211, :216) get no vended credential.
  - The sink fragment can run on a different backend than the scan (after an 
exchange).
  - Finalization on a dedicated coordinator (FinalizeHdfsInsert, 
coordinator.cc:991): its query_state_ scanned nothing.
  - On a single backend, another fragment may call GetConnection before the 
scan registers, and its local cache then keeps the non-vended connection.

  Impact: writes and finalization for a REST table that the query doesn't scan 
on that backend use the cluster's own credentials instead of the vended ones. 
On a cluster without its own S3
  credentials (the usual reason to use vending), the write fails with a 403. On 
a cluster with them, it bypasses the storage scoping the catalog intended.


http://gerrit.cloudera.org:8080/#/c/24838/9/be/src/runtime/hdfs-fs-cache.cc
File be/src/runtime/hdfs-fs-cache.cc:

http://gerrit.cloudera.org:8080/#/c/24838/9/be/src/runtime/hdfs-fs-cache.cc@244
PS9, Line 244:       VLOG(1) << "Dropping hdfsFS of " << (expired ? "expired" : 
"idle")
The FileHandleCache can keep handles on vended connections after they are 
disconnected here, and it shares handles across credentials. The DiskIoMgr's 
FileHandleCache is process-wide and
  caches S3 handles by default (--cache_s3_file_handles=true, unused handles 
live up to 6 h). Each CachedHdfsFileHandle stores the hdfsFS it was opened on, 
but the cache key is only (fname,
  mtime) (handle-cache.inline.h:150), so:
  1. Query A reads f.parquet through vended connection X, and the handle stays 
cached.
  2. A finishes; an hour later X is idle, gets evicted, and hdfsDisconnect(X) 
closes its FileSystem.
  3. Query B reads f.parquet, hits the cache, and gets a handle bound to the 
closed FileSystem. When the cache later evicts it, hdfsCloseFile runs on a 
disconnected fs.

  Even without the disconnect, query B can reuse a handle that query A opened 
with A's credential, or a cluster-credential handle can serve a vended table 
and the other way round. S3A uses
  that credential again when it reopens the stream on a seek.

  Impact:
  - Reads use credentials the query didn't get. A cached handle keeps reading 
with the credential it was opened with, for up to 6 h. So a credential the 
catalog has since narrowed or revoked
    keeps working through cached handles, and reads can mix vended and cluster 
credentials for the same file. That undermines the catalog-scoped storage 
access that vending is for. Ranger
    still applies in the FE, so this is about storage-level access, not 
user-level authorization.
  - Wasted reads and confusing errors. A read through a handle on a 
disconnected or expired connection fails first. HdfsFileReader then reopens the 
handle with the current query's connection
    and retries (hdfs-file-reader.cc:184-200), so the query usually succeeds, 
but every such handle costs a failed request plus a reopen, and logs a 
misleading error.
  - Lifetime. Cached handles keep S3A streams (and their HTTP connections) 
alive after HdfsFsCache considers the connection released. Eviction then calls 
hdfsCloseFile on a disconnected fs,
    with the return code ignored (handle-cache.inline.h:35).



--
To view, visit http://gerrit.cloudera.org:8080/24838
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I73592a1521f29374316ed001341f956b40f9c0d5
Gerrit-Change-Number: 24838
Gerrit-PatchSet: 9
Gerrit-Owner: Peter Rozsa <[email protected]>
Gerrit-Reviewer: Impala Public Jenkins <[email protected]>
Gerrit-Reviewer: Nandor Kollar <[email protected]>
Gerrit-Reviewer: Peter Rozsa <[email protected]>
Gerrit-Reviewer: Zoltan Borok-Nagy <[email protected]>
Gerrit-Comment-Date: Thu, 29 Oct 2026 12:31:50 +0000
Gerrit-HasComments: Yes

Reply via email to