Skip to content

Commit

Permalink
fix(jdbc): log executionId could be null
Browse files Browse the repository at this point in the history
  • Loading branch information
tchiotludo committed Dec 8, 2023
1 parent 0fa6964 commit 6699436
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,6 @@ void schedule() throws Exception {
.when(flowListenersServiceSpy)
.flows();

logQueue.receive(e -> {
if (e.getLeft().getMessage().contains("Unknown time-zone ID: Asia/Delhi")) {
invalidLogCount.countDown();
}
});

// scheduler
try (AbstractScheduler scheduler = scheduler(flowListenersServiceSpy);
Worker worker = new TestMethodScopedWorker(applicationContext, 8, null)) {
Expand All @@ -110,12 +104,19 @@ void schedule() throws Exception {
assertThat(execution.getFlowId(), is(flow.getId()));
});

Runnable logStop = logQueue.receive(e -> {
if (e.getLeft().getMessage().contains("Unknown time-zone ID: Asia/Delhi")) {
invalidLogCount.countDown();
}
});

worker.run();
scheduler.run();
queueCount.await(1, TimeUnit.MINUTES);
invalidLogCount.await(1, TimeUnit.MINUTES);
// needed for RetryingTest to work since there is no context cleaning between method => we have to clear assertion receiver manually
assertionStop.run();
logStop.run();

assertThat(queueCount.getCount(), is(0L));
assertThat(date.size(), is(3));
Expand Down
13 changes: 13 additions & 0 deletions jdbc-h2/src/main/resources/migrations/h2/V1_13__log_fulltext.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
alter table logs alter column "execution_id" drop not null;

ALTER TABLE logs
ALTER COLUMN "fulltext" TEXT NOT NULL GENERATED ALWAYS AS (
JQ_STRING("value", '.namespace') ||
JQ_STRING("value", '.flowId') ||
COALESCE(JQ_STRING("value", '.taskId'), '') ||
COALESCE(JQ_STRING("value", '.executionId'), '') ||
COALESCE(JQ_STRING("value", '.taskRunId'), '') ||
COALESCE(JQ_STRING("value", '.triggerId'), '') ||
COALESCE(JQ_STRING("value", '.message'), '') ||
COALESCE(JQ_STRING("value", '.thread'), '')
);
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE `logs` MODIFY `execution_id` VARCHAR(150) GENERATED ALWAYS AS (value ->> '$.executionId') STORED;
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
ALTER TABLE logs DROP COLUMN fulltext;

ALTER TABLE logs ADD COLUMN fulltext TSVECTOR GENERATED ALWAYS AS (
FULLTEXT_INDEX(CAST(value ->> 'namespace' AS varchar)) ||
FULLTEXT_INDEX(CAST(value ->> 'flowId' AS varchar)) ||
FULLTEXT_INDEX(COALESCE(CAST(value ->> 'taskId' AS varchar), '')) ||
FULLTEXT_INDEX(COALESCE(CAST(value ->> 'executionId' AS varchar), '')) ||
FULLTEXT_INDEX(COALESCE(CAST(value ->> 'taskRunId' AS varchar), '')) ||
FULLTEXT_INDEX(COALESCE(CAST(value ->> 'triggerId' AS varchar), '')) ||
FULLTEXT_INDEX(COALESCE(CAST(value ->> 'message' AS varchar), '')) ||
FULLTEXT_INDEX(COALESCE(CAST(value ->> 'thread' AS varchar), ''))
) STORED

0 comments on commit 6699436

Please sign in to comment.