[Fix](point query) OlapScanNode reuslt could be memleak since it's cached (#16406)
Cached OlapScanNode each time call `addScanRangeLocations` will add TScanRangeLocations to result. So `result` could grow too large and lead `getReplicaNumPerHost` a cpu hot spot in it's loop.
This commit is contained in:
@ -978,6 +978,7 @@ public class OlapScanNode extends ScanNode {
|
||||
computePartitionInfo();
|
||||
scanBackendIds.clear();
|
||||
scanTabletIds.clear();
|
||||
result.clear();
|
||||
try {
|
||||
getScanRangeLocations();
|
||||
} catch (AnalysisException e) {
|
||||
|
||||
@ -1615,24 +1615,23 @@ public class Coordinator {
|
||||
// Populates scan_range_assignment_.
|
||||
// <fragment, <server, nodeId>>
|
||||
private void computeScanRangeAssignment() throws Exception {
|
||||
if (isPointQuery) {
|
||||
// Fast path for evaluate Backend for point query
|
||||
List<TScanRangeLocations> locations = ((OlapScanNode) scanNodes.get(0)).lazyEvaluateRangeLocations();
|
||||
Preconditions.checkNotNull(locations);
|
||||
return;
|
||||
}
|
||||
Map<TNetworkAddress, Long> assignedBytesPerHost = Maps.newHashMap();
|
||||
Map<TNetworkAddress, Long> replicaNumPerHost = getReplicaNumPerHost();
|
||||
Collections.shuffle(scanNodes);
|
||||
// set scan ranges/locations for scan nodes
|
||||
for (ScanNode scanNode : scanNodes) {
|
||||
List<TScanRangeLocations> locations;
|
||||
if (isPointQuery) {
|
||||
// Fast path for evaluate Backend for point query
|
||||
locations = ((OlapScanNode) scanNode).lazyEvaluateRangeLocations();
|
||||
Preconditions.checkNotNull(locations);
|
||||
return;
|
||||
} else {
|
||||
// the parameters of getScanRangeLocations may ignore, It doesn't take effect
|
||||
locations = scanNode.getScanRangeLocations(0);
|
||||
if (locations == null) {
|
||||
// only analysis olap scan node
|
||||
continue;
|
||||
}
|
||||
// the parameters of getScanRangeLocations may ignore, It doesn't take effect
|
||||
locations = scanNode.getScanRangeLocations(0);
|
||||
if (locations == null) {
|
||||
// only analysis olap scan node
|
||||
continue;
|
||||
}
|
||||
Collections.shuffle(locations);
|
||||
Set<Integer> scanNodeIds = fragmentIdToScanNodeIds.computeIfAbsent(scanNode.getFragmentId(),
|
||||
|
||||
Reference in New Issue
Block a user