-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Add upsert support for offline tables #17789
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,6 +31,7 @@ | |
| import org.apache.pinot.common.exception.TableNotFoundException; | ||
| import org.apache.pinot.common.metrics.ServerQueryPhase; | ||
| import org.apache.pinot.core.data.manager.InstanceDataManager; | ||
| import org.apache.pinot.core.data.manager.offline.OfflineTableDataManager; | ||
| import org.apache.pinot.core.data.manager.realtime.RealtimeTableDataManager; | ||
| import org.apache.pinot.core.query.pruner.SegmentPrunerService; | ||
| import org.apache.pinot.core.query.pruner.SegmentPrunerStatistics; | ||
|
|
@@ -81,10 +82,9 @@ public static SingleTableExecutionInfo create(InstanceDataManager instanceDataMa | |
| indexSegments.add(segmentDataManager.getSegment()); | ||
| } | ||
| } else { | ||
| RealtimeTableDataManager rtdm = (RealtimeTableDataManager) tableDataManager; | ||
| TableUpsertMetadataManager tumm = rtdm.getTableUpsertMetadataManager(); | ||
| TableUpsertMetadataManager tumm = getTableUpsertMetadataManager(tableDataManager); | ||
| boolean isUsingConsistencyMode = | ||
| rtdm.getTableUpsertMetadataManager().getContext().getConsistencyMode() != UpsertConfig.ConsistencyMode.NONE; | ||
| tumm.getContext().getConsistencyMode() != UpsertConfig.ConsistencyMode.NONE; | ||
| if (isUsingConsistencyMode) { | ||
|
Comment on lines
+85
to
88
|
||
| tumm.lockForSegmentContexts(); | ||
| } | ||
|
|
@@ -134,12 +134,25 @@ private static boolean isUpsertTable(TableDataManager tableDataManager) { | |
| // those segments in the list of segments for query to process on the server, otherwise, the query will see less | ||
| // than expected valid docs from the upsert table. | ||
| if (tableDataManager instanceof RealtimeTableDataManager) { | ||
| RealtimeTableDataManager rtdm = (RealtimeTableDataManager) tableDataManager; | ||
| return rtdm.isUpsertEnabled(); | ||
| return ((RealtimeTableDataManager) tableDataManager).isUpsertEnabled(); | ||
| } | ||
| if (tableDataManager instanceof OfflineTableDataManager) { | ||
| return ((OfflineTableDataManager) tableDataManager).isUpsertEnabled(); | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| @Nullable | ||
| private static TableUpsertMetadataManager getTableUpsertMetadataManager(TableDataManager tableDataManager) { | ||
| if (tableDataManager instanceof RealtimeTableDataManager) { | ||
| return ((RealtimeTableDataManager) tableDataManager).getTableUpsertMetadataManager(); | ||
| } | ||
| if (tableDataManager instanceof OfflineTableDataManager) { | ||
| return ((OfflineTableDataManager) tableDataManager).getTableUpsertMetadataManager(); | ||
| } | ||
| return null; | ||
| } | ||
|
|
||
| private SingleTableExecutionInfo(TableDataManager tableDataManager, List<SegmentDataManager> segmentDataManagers, | ||
| List<IndexSegment> indexSegments, Map<IndexSegment, SegmentContext> providedSegmentContexts, | ||
| List<String> segmentsToQuery, List<String> optionalSegments, List<String> notAcquiredSegments) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Offline upsert path doesn’t handle the partition upsert metadata manager’s preload mode. Unlike RealtimeTableDataManager, this code never calls
preloadSegments(...)and doesn’t branch onpartitionUpsertMetadataManager.isPreloading()to usepreloadSegment(...). If preload is enabled in the upsert config, the preload flag may remain true and segments will be processed via the slower add/replace path (and potentially with different registration ordering than intended). Consider adding the preload trigger (based on ZK metadata partition id) and a preload branch mirroring the realtime implementation.