waterWang opened a new pull request, #17586:
URL: https://github.com/apache/iceberg/pull/17586

   Fixes #17585
   
   `RESTTableCache` caches `TableMetadata` and shares it across threads. 
`TableMetadata` lazily-initializes fields in `BaseSnapshot` and `Schema` 
without synchronization, while `PartitionSpec` correctly uses `synchronized` + 
`volatile` (double-checked locking).
   
   This PR applies the same thread-safe lazy-initialization pattern:
   
   - **BaseSnapshot**: mark 7 lazy fields `volatile` and guard 
`allManifests`/`dataManifests`/`deleteManifests`/`addedDataFiles`/`removedDataFiles`/`addedDeleteFiles`/`removedDeleteFiles`
 getters with double-checked locking (`synchronized (this)` + inner null check).
   - **Schema**: mark 7 lazy fields `volatile` and guard the 6 `lazy*()` 
initializers (`lazyIdToField`, `lazyNameToId`, `lazyIdToName`, 
`lazyLowerCaseNameToId`, `lazyIdToAccessor`, `lazyIdentifierFieldIdSet`) with 
double-checked locking.
   
   This eliminates the data race on lazily-initialized fields when 
`TableMetadata` is shared across threads (e.g. via `RESTSessionCatalog`'s 
`RESTTableCache`), matching the existing `PartitionSpec` pattern.


-- 
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