apache / amoro

Apache Amoro (incubating) is a Lakehouse management system built on open data lake formats.
https://amoro.apache.org/
Apache License 2.0
874 stars 290 forks source link

[AMORO-3286] Fix ConcurrentModificationException in TableRuntime.getQuotaTime() #3292

Closed guilherme-dsantos closed 4 weeks ago

guilherme-dsantos commented 1 month ago

Fix/Resolve #3286

Changes made:

Technical details:

Testing:

Code changes:


public long getQuotaTime() {
    long calculatingEndTime = System.currentTimeMillis();
    long calculatingStartTime = calculatingEndTime - AmoroServiceConstants.QUOTA_LOOK_BACK_TIME;
    long finishedTaskQuotaTime;
    synchronized (taskQuotas) {
        taskQuotas.removeIf(task -> task.checkExpired(calculatingStartTime));
        finishedTaskQuotaTime = taskQuotas.stream()
                .mapToLong(taskQuota -> taskQuota.getQuotaTime(calculatingStartTime))
                .sum();
    }
    return optimizingProcess == null
            ? finishedTaskQuotaTime
            : finishedTaskQuotaTime
            + optimizingProcess.getRunningQuotaTime(calculatingStartTime, calculatingEndTime);
}