Skip to content

Commit

Permalink
bugfix: default persistor should not swallow exceptions thrown when a… (
Browse files Browse the repository at this point in the history
#141)

* bugfix: default persistor should not swallow exceptions thrown when a unique request id is present on a txoutbox entry.
* +1 invocation `text` -> `mediumtext` for mysql dialects.

(cherry picked from commit 93aad05)
  • Loading branch information
victokoh authored and badgerwithagun committed Aug 22, 2021
1 parent 4dd8da5 commit 560e8db
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,13 @@ public Stream<SqlMigration> migrations(String tableName) {
+ tableName
+ " ADD COLUMN lastAttemptTime TIMESTAMP(6) NULL AFTER invocation"),
new SqlMigration(
8,
8, "Update length of invocation column on outbox for MySQL dialects only.", ""),
new SqlMigration(
9,
"Make nextAttemptTime not null",
"ALTER TABLE " + tableName + " ALTER COLUMN nextAttemptTime TIMESTAMP(6) NOT NULL"),
new SqlMigration(
9,
10,
"Fix data types on blocked and processed columns",
String.format(
"UPDATE %s SET blocked = false WHERE blocked IS NULL;\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,24 @@ public Stream<SqlMigration> migrations(String tableName) {
+ " ADD COLUMN lastAttemptTime TIMESTAMP(6) NULL AFTER invocation"),
new SqlMigration(
8,
"Update length of invocation column on outbox for MySQL dialects only.",
"ALTER TABLE TXNO_OUTBOX MODIFY COLUMN invocation MEDIUMTEXT"),
new SqlMigration(
9,
"Use datetime datatype for the next process date",
"ALTER TABLE " + tableName + " MODIFY COLUMN nextAttemptTime DATETIME(6) NOT NULL"),
new SqlMigration(
9,
10,
"Repair nulls on blocked column",
String.format(
"UPDATE %s SET blocked = CASE WHEN blocked = 'TRUE' or blocked = 'true' or blocked = '1' or blocked = 't' or blocked = 'y' or blocked = 'yes' or blocked = 'on' THEN '1' ELSE '0' END",
tableName)),
new SqlMigration(
10,
11,
"Repair nulls on processed column",
String.format("UPDATE %s SET processed = 0 WHERE processed IS NULL", tableName)),
new SqlMigration(
11,
12,
"Fix data types on blocked and processed columns",
String.format(
"ALTER TABLE %s\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,13 @@ public Stream<SqlMigration> migrations(String tableName) {
"Add lastAttemptTime column to outbox",
"ALTER TABLE " + tableName + " ADD COLUMN lastAttemptTime TIMESTAMP(6) NULL"),
new SqlMigration(
8,
8, "Update length of invocation column on outbox for MySQL dialects only.", ""),
new SqlMigration(
9,
"Make nextAttemptTime not null",
"ALTER TABLE " + tableName + " ALTER COLUMN nextAttemptTime SET NOT NULL"),
new SqlMigration(
9,
10,
"Fix data types on blocked and processed columns",
String.format(
"UPDATE %s SET processed = FALSE WHERE processed IS NULL;\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.gruelbox.transactionoutbox.OptimisticLockException;
import com.gruelbox.transactionoutbox.Persistor;
import com.gruelbox.transactionoutbox.TransactionOutboxEntry;
import com.gruelbox.transactionoutbox.Utils;
import com.gruelbox.transactionoutbox.spi.BaseTransaction;
import com.gruelbox.transactionoutbox.spi.BaseTransactionManager;
import java.math.BigDecimal;
Expand Down Expand Up @@ -92,6 +93,17 @@ void testInsertAndSelect() {
assertThat(entries, contains(entry));
}

@Test
void testInsertWithUniqueRequestIdFailureBubblesExceptionUp() {
var invalidEntry =
createEntry("FOO", now, false).toBuilder()
.uniqueRequestId("INTENTIONALLY_TOO_LONG_TO_CAUSE_BLOW_UP".repeat(10))
.build();
assertThrows(
RuntimeException.class,
() -> Utils.join(txManager().transactionally(tx -> persistor().save(tx, invalidEntry))));
}

@Test
void testInsertDuplicate() {
TransactionOutboxEntry entry1 = createEntry("FOO1", now, false, "context-clientkey1");
Expand Down

0 comments on commit 560e8db

Please sign in to comment.