-
Notifications
You must be signed in to change notification settings - Fork 249
Support retrying non-finished async tasks on startup and periodically #1585
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
994567a
6d2040d
448b150
4e0a6c6
a815e3e
218e5f5
d1d15d7
a5d8f56
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 |
---|---|---|
|
@@ -24,7 +24,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.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
@@ -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( | ||
|
@@ -103,7 +107,7 @@ void setup() { | |
metaStoreManagerFactory.getOrCreateSessionSupplier(realmContext).get(), | ||
diagServices, | ||
configurationStore, | ||
Clock.systemDefaultZone()); | ||
timeSource); | ||
|
||
callContext = CallContext.of(realmContext, polarisCallContext); | ||
} | ||
|
@@ -152,6 +156,7 @@ 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. Previously, task entity might miss 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. Can you explain this further - I'm not sure why the tests need this 10m jump? Is it so that tasks are "recovered" by the Quarkus Scheduled method? |
||
assertThat( | ||
metaStoreManagerFactory | ||
.getOrCreateMetaStoreManager(realmContext) | ||
|
@@ -232,6 +237,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) | ||
|
@@ -293,6 +299,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) | ||
|
@@ -413,6 +420,7 @@ public void testTableCleanupMultipleSnapshots() throws IOException { | |
|
||
handler.handleTask(task, callContext); | ||
|
||
timeSource.add(Duration.ofMinutes(10)); | ||
List<PolarisBaseEntity> entities = | ||
metaStoreManagerFactory | ||
.getOrCreateMetaStoreManager(realmContext) | ||
|
@@ -587,6 +595,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.
To make this a bit more defensively-coded, I might recommend making this into a iterator of Map.Entry objects, given that this is a public method and we wouldn't want any code path to be able to modify this mapping?