You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Polaris persistence mandates the use of transactions & serializable isolation #766
Despite that PolarisMetaStoreSessionclearly says that it [is] really easy to back this using [...] simpler KV store. the whole code architecture of everything around persistence in Polaris requires nothing less than (relational) transactions and strong consistency across multiple rows in multiple tables.
For example org.apache.polaris.core.persistence.PolarisMetaStoreManagerImpl#writeEntity:
works against 2-3 different rows in 2-3 different tables, requiring that all or none of the changes succeed - this is multiplied by the number of entities being written. On top it requires that entities being read before (existing and non-existing) did not change when the tx gets committed.
The "pattern" of having these different tables leaks into a lot of places. It effectively makes it rather impossible to use anything else than a relational database w/ isolation level SERIALIZABLE.
The current code structure probably exaggerates the expected transaction semantics needlessly, and a few minor adjustments should be able to significantly lighten the requirements. In particular:
Most of the independent one-shot reads happen to be structured as runInReadTransaction but aren't actually depending on transaction semantics
The writeToEntities, writeToEntitiesChangeTracking, writeToEntitiesActive triplet is actually more for serving the role of secondary indexes than truly being separate tables. There are caveats depending on how we approach vestigial plans for UNDROP functionality, but it's worth discussing whether these make sense to push down to the MetaStoreSession layer and even refactoring the EclipseLink one to better portray these as serving efficient queries on a single table
A few operations actually do uniquely require various flavors of transactions across multiple rows or tables; we should enumerate these separately from the majority of "core" actions. Of particular interest off the top of my head:
a. CreateCatalog relationship to a "storage integration" object and bootstrapped CatalogRoles
b. CreatePrincipal with "principal secrets"
c. Iceberg-level multi-table commit that uses updateEntitiesPropertiesIfNotChanged
d. DropTable atomically adding a TaskEntity for cleanup (other DropEntity types as well technically, but the main non-trivial case is for file cleanup when PURGE=true)
Activity
dennishuo commentedon Jan 23, 2025
The current code structure probably exaggerates the expected transaction semantics needlessly, and a few minor adjustments should be able to significantly lighten the requirements. In particular:
runInReadTransactionbut aren't actually depending on transaction semanticswriteToEntities,writeToEntitiesChangeTracking,writeToEntitiesActivetriplet is actually more for serving the role of secondary indexes than truly being separate tables. There are caveats depending on how we approach vestigial plans for UNDROP functionality, but it's worth discussing whether these make sense to push down to theMetaStoreSessionlayer and even refactoring the EclipseLink one to better portray these as serving efficient queries on a single tablea. CreateCatalog relationship to a "storage integration" object and bootstrapped CatalogRoles
b. CreatePrincipal with "principal secrets"
c. Iceberg-level multi-table commit that uses updateEntitiesPropertiesIfNotChanged
d. DropTable atomically adding a TaskEntity for cleanup (other DropEntity types as well technically, but the main non-trivial case is for file cleanup when PURGE=true)
dennishuo commentedon Feb 4, 2025
Wrote up some analysis and tentative proposal for the way forward that should get us pretty far with fairly minimal changes:
https://docs.google.com/document/d/1U9rprj8w8-Q0SnQvRMvoVlbX996z-89eOkVwWTQaZG0/edit?tab=t.0