-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(jdbc): be resilient to DataException
We usually fail fast, but when a DataException is thrown it means the JDBC driver throws an exception with error code 22: data exception. As the exception is from the data not the database or the network, there is no point of failfast, we throw a QueueException that may or may not be handled gracefully by the call site.
- Loading branch information
1 parent
bd6937a
commit 0d61c3e
Showing
3 changed files
with
51 additions
and
10 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
jdbc-postgres/src/test/java/io/kestra/runner/postgres/PostgresQueueTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,38 @@ | ||
package io.kestra.runner.postgres; | ||
|
||
import io.kestra.core.models.executions.TaskRun; | ||
import io.kestra.core.models.flows.State; | ||
import io.kestra.core.queues.QueueException; | ||
import io.kestra.core.runners.WorkerTaskResult; | ||
import io.kestra.core.utils.IdUtils; | ||
import io.kestra.jdbc.runner.JdbcQueueTest; | ||
import org.jooq.exception.DataException; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.Map; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.instanceOf; | ||
import static org.hamcrest.Matchers.is; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
||
class PostgresQueueTest extends JdbcQueueTest { | ||
@Test | ||
void invalidWorkerTaskShouldThrowDataException() throws QueueException { | ||
var workerTaskResult = WorkerTaskResult.builder() | ||
.taskRun(TaskRun.builder() | ||
.taskId("taskId") | ||
.id(IdUtils.create()) | ||
.namespace("namespace") | ||
.flowId("flowId") | ||
.state(new State().withState(State.Type.SUCCESS)) | ||
.outputs(Map.of("value", "\u0000")) | ||
.build() | ||
) | ||
.build(); | ||
|
||
var exception = assertThrows(QueueException.class, () -> workerTaskResultQueue.emit(workerTaskResult)); | ||
assertThat(exception.getMessage(), is("Unable to emit a message to the queue")); | ||
assertThat(exception.getCause(), instanceOf(DataException.class)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters