PHOENIX-7795 : Tenant TTL using Tenant Views on Multi-Tenant Table#2400
PHOENIX-7795 : Tenant TTL using Tenant Views on Multi-Tenant Table#2400palashc wants to merge 14 commits into
Conversation
jpisaac
left a comment
There was a problem hiding this comment.
Looks good, Few test suggestions
Code Review: PHOENIX-7795 PR #2400 — Tenant TTL using Tenant Views on Multi-Tenant TableSummaryThorough review (two rounds, extreme depth) covering the new validation, [MEDIUM]
|
Changes Summary — PR Review Round 2Issue 1:
|
| Suite | Tests | Result |
|---|---|---|
TenantTTLIT |
16 | Pass |
TenantIdTypeIT |
15 | Pass (no regression) |
ViewTTLIT |
68 | Pass (no regression) |
FYI @jpisaac
Summary
Enable per-tenant TTL on multi-tenant base tables by letting a tenant create a view without a
WHEREclause and set TTL on it. Read masking and compaction use the existing View TTL infrastructure.Changes
WhereOptimizer.getRowKeyMatcher: computeROW_KEY_MATCHERfrom the connection's tenant-id when a tenant view is created without aWHEREclause, so it participates in the compactionRowKeyMatchertrie. WrapsScanUtil.getTenantIdBytesin try/catch to avoid breaking creation when the tenant-id type doesn't match the schema.CreateTableCompiler.compile: always invokegetRowKeyMatcherforUPDATABLEviews (no longer gated onwhere != null).New validation (
ViewUtil.validateTenantViewWithoutWhereTTLCoexistence)On a multi-tenant base table, among a given tenant's views without a WHERE clause, we allow either:
Multiple no-WHERE TTL views share the same
ROW_KEY_MATCHER(tenant-id bytes) and would conflict in the compactionRowKeyMatchertrie. The check rejects such operations withTENANT_VIEW_WITHOUT_WHERE_TTL_CONFLICT. Views withWHEREclauses are out of scope for this check (their prefix-conflict potential is a pre-existing concern tracked separately).The helper lives in
ViewUtiland is invoked from:CREATE VIEW(CreateTableCompiler) when creating a no-WHERE view on a multi-tenant base table.ALTER VIEW SET TTL(MetaDataClient.evaluateStmtProperties) when the view being altered is a no-WHERE tenant view on a multi-tenant base table; the view itself is excluded from the sibling check.Gracefully skips when
CHILD_LINKis unavailable (namespace mapping edge cases) or in connectionless mode (unit tests).Tests (
TenantTTLIT)testReadMaskingWithDifferentTenantTTLstestCompactionWithDifferentTenantTTLs— INTEGER non-tenant PKtestThreeTenantsDifferentTTLs—CHAR(3)+BIGINTPK columnstestCompactionWithSplitRegions— pre-split base tabletestCompactionWithSaltedMultiTenantTabletestCompactionWithTenantTableIndex— with secondary index on the base tabletestSameViewNameAcrossDifferentTenantstestTenantTTLWithUpdatableViewRestrictionEnabledtestTenantTTLViewCoexistenceRules— 9 cases exercising every CREATE-path branch (no-WHERE non-TTL, no-WHERE TTL, mixed, different tenants, newly-allowed WHERE-scoped creations)testAlterTTLOnTenantViewWithSiblingIsRejected— ALTER-path rejection for no-WHERE viewstestAlterTTLOnWhereScopedTenantViewIsAllowed— ALTER-path allowed for WHERE-scoped viewstestAlterTenantViewToAddTTL— ALTER TTL masking/compaction end-to-endtestChildViewsOfTenantTTLViewInheritTTL— child views inherit parent tenant view's TTL