github-actions[bot] commented on code in PR #68042:
URL: https://github.com/apache/doris/pull/68042#discussion_r4220536704
##########
fe/fe-core/src/main/java/org/apache/doris/datasource/doris/RemoteDorisExternalTable.java:
##########
@@ -62,62 +62,88 @@ protected synchronized void makeSureInitialized() {
}
private RemoteOlapTable getDorisOlapTable() {
- if (!isSyncOlapTable) {
- synchronized (this) {
- if (!isSyncOlapTable) {
- try {
- isSyncOlapTable = true;
- remoteOlapTable = null;
- lastException = null; // clear previous exception
-
- List<Partition> cachedPartitions =
Lists.newArrayList(partitions);
- List<Partition> cachedTempPartitions =
Lists.newArrayList(tempPartitions);
- RemoteOlapTable olapTable =
((RemoteDorisExternalCatalog) catalog).getFeServiceClient()
- .getOlapTable(dbName, remoteName, tableId,
cachedPartitions, cachedTempPartitions);
- olapTable.setCatalog((RemoteDorisExternalCatalog)
catalog);
- olapTable.setDatabase((RemoteDorisExternalDatabase)
db);
-
- // Remove redundant nested synchronized block
- tableId = olapTable.getId();
- partitions =
Lists.newArrayList(olapTable.getPartitions());
- tempPartitions =
Lists.newArrayList(olapTable.getTempPartitions().getPartitions());
-
- olapTable.setId(id); // change id in case of possible
conflicts
- olapTable.invalidateBackendsIfNeed();
- remoteOlapTable = olapTable;
- } catch (Exception e) {
- // Save exception for waiting threads
- lastException = e;
- LOG.warn("Failed to get remote doris olap table:
{}.{}", dbName, remoteName, e);
- throw e; // Re-throw the exception
- } finally {
- isSyncOlapTable = false;
- this.notifyAll();
- }
- return remoteOlapTable;
- }
+ RefreshTask refreshTask;
+ synchronized (this) {
+ if (latestRefreshTask == null || latestRefreshTask.isStarted()) {
+ FutureTask<RemoteOlapTable> predecessor =
+ latestRefreshTask == null ? null :
latestRefreshTask.task;
+ latestRefreshTask = new RefreshTask(predecessor);
}
+ refreshTask = latestRefreshTask;
}
- synchronized (this) {
- while (isSyncOlapTable) {
- try {
- this.wait();
- } catch (InterruptedException e) {
- throw new AnalysisException("interrupted while getting
doris olap table", e);
- }
- }
+ refreshTask.run();
+ return getRefreshResult(refreshTask.task);
+ }
+
+ private class RefreshTask {
+ private final FutureTask<RemoteOlapTable> task;
+ private final FutureTask<RemoteOlapTable> predecessor;
+ private volatile boolean started;
Review Comment:
[P2] Release the completed predecessor result after it orders the successor.
The table retains `latestRefreshTask`, whose final `predecessor` field keeps
the previous completed FutureTask and its `RemoteOlapTable` outcome reachable.
After this successor finishes, the old table maps and any superseded
partition/tablet objects remain pinned until another refresh or table eviction,
adding avoidable FE heap use for large partition sets. Drop that reference once
predecessor completion is established, with safe publication for concurrent
runners.
--
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]