-
Notifications
You must be signed in to change notification settings - Fork 271
Support retrying non-finished async tasks on startup and periodically #2003
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: main
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 |
---|---|---|
|
@@ -26,7 +26,9 @@ | |
import jakarta.annotation.Nonnull; | ||
import jakarta.inject.Inject; | ||
import java.io.IOException; | ||
import java.time.Clock; | ||
import java.time.Duration; | ||
import java.time.Instant; | ||
import java.time.ZoneOffset; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Set; | ||
|
@@ -68,6 +70,7 @@ | |
import org.junit.jupiter.api.Test; | ||
import org.mockito.Mockito; | ||
import org.slf4j.LoggerFactory; | ||
import org.threeten.extra.MutableClock; | ||
|
||
@QuarkusTest | ||
class TableCleanupTaskHandlerTest { | ||
|
@@ -78,6 +81,7 @@ class TableCleanupTaskHandlerTest { | |
private CallContext callContext; | ||
|
||
private final RealmContext realmContext = () -> "realmName"; | ||
private final MutableClock timeSource = MutableClock.of(Instant.now(), ZoneOffset.UTC); | ||
|
||
private TaskFileIOSupplier buildTaskFileIOSupplier(FileIO fileIO) { | ||
return new TaskFileIOSupplier( | ||
|
@@ -106,7 +110,7 @@ void setup() { | |
metaStoreManagerFactory.getOrCreateSessionSupplier(realmContext).get(), | ||
diagServices, | ||
configurationStore, | ||
Clock.systemDefaultZone()); | ||
timeSource); | ||
} | ||
|
||
@Test | ||
|
@@ -147,6 +151,8 @@ public void testTableCleanup() throws IOException { | |
|
||
handler.handleTask(task, callContext); | ||
|
||
timeSource.add(Duration.ofMinutes(10)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @adnanhemani continue the previous comment here:
In this test, the new tasks are created and not executed by its parent task, so to ensure these tasks are fetched, we need to simulate a time gap longer than 5 minutes. |
||
|
||
assertThat( | ||
metaStoreManagerFactory | ||
.getOrCreateMetaStoreManager(realmContext) | ||
|
@@ -227,6 +233,7 @@ public void close() { | |
assertThat(results).containsExactly(true, true); | ||
|
||
// both tasks successfully executed, but only one should queue subtasks | ||
timeSource.add(Duration.ofMinutes(10)); | ||
assertThat( | ||
metaStoreManagerFactory | ||
.getOrCreateMetaStoreManager(realmContext) | ||
|
@@ -288,6 +295,7 @@ public void close() { | |
assertThat(results).containsExactly(true, true); | ||
|
||
// both tasks successfully executed, but only one should queue subtasks | ||
timeSource.add(Duration.ofMinutes(10)); | ||
assertThat( | ||
metaStoreManagerFactory | ||
.getOrCreateMetaStoreManager(realmContext) | ||
|
@@ -408,6 +416,7 @@ public void testTableCleanupMultipleSnapshots() throws IOException { | |
|
||
handler.handleTask(task, callContext); | ||
|
||
timeSource.add(Duration.ofMinutes(10)); | ||
List<PolarisBaseEntity> entities = | ||
metaStoreManagerFactory | ||
.getOrCreateMetaStoreManager(realmContext) | ||
|
@@ -582,6 +591,7 @@ public void testTableCleanupMultipleMetadata() throws IOException { | |
|
||
handler.handleTask(task, callContext); | ||
|
||
timeSource.add(Duration.ofMinutes(10)); | ||
List<PolarisBaseEntity> entities = | ||
metaStoreManagerFactory | ||
.getOrCreateMetaStoreManager(callContext.getRealmContext()) | ||
|
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.
Make it to Iter<Map.Entry> as https://github.com/apache/polaris/pull/1585/files#r2121942046 suggests