ajantha-bhat opened a new pull request, #17532:
URL: https://github.com/apache/iceberg/pull/17532

   `loadView()` created a `ViewOperations` instance and called `ops.current()` 
to verify that the view exists. That refresh asks the catalog for the current 
metadata location and reads the metadata file, so a successful call means that 
ops has already loaded a readable view metadata snapshot.
   
   The method then discarded that loaded ops and returned a `BaseView` backed 
by a second, freshly constructed `ViewOperations` instance. `BaseView` reads 
metadata lazily, so the caller's first access, such as `view.schema()`, 
triggered another refresh instead of using the metadata that `loadView()` had 
already loaded.
   
   That second refresh is not just redundant. With Hive-backed 
`ViewOperations`, it re-queries HMS for the view's `metadata_location` and 
reads the referenced metadata JSON again. If a concurrent commit, drop, 
replace, cleanup, or storage visibility issue changes HMS or the files between 
the two reads, `loadView()` can succeed on one metadata version while the 
returned View immediately fails while reading another or no-longer-readable 
metadata location.
   
   The race looks like this:
   
   T1: `loadView` starts
   T2: ops1 refreshes HMS -> metadata v1, reads v1 successfully
   T3: `loadView` discards ops1 and returns BaseView with ops2
   T4: concurrent commit/drop/replace/cleanup/storage visibility issue changes 
HMS or files
   T5: caller asks `view.schema()`
   T6: ops2 refreshes HMS again -> maybe metadata v2
   T7: reading v2 fails
   
   Reuse the validated `ViewOperations` instance so the returned View is backed 
by the same loaded metadata snapshot that passed the existence check. This also 
matches `BaseMetastoreCatalog#loadTable,` which returns a `BaseTable` using the 
`TableOperations` instance it already refreshed.
   
   Adds shared `ViewCatalogTests` coverage asserting that 
`BaseMetastoreViewCatalog#loadView` constructs exactly one `ViewOperations` 
instance and returns a View backed by that same validated instance.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to