Skip to content

DelayedQueueJDBC with initial HSQL Support#2

Merged
alexandru merged 21 commits intomainfrom
retries
Feb 6, 2026
Merged

DelayedQueueJDBC with initial HSQL Support#2
alexandru merged 21 commits intomainfrom
retries

Conversation

@alexandru
Copy link
Copy Markdown
Member

@alexandru alexandru commented Feb 6, 2026

Introduces DelayedQueueJDBC based on HSQLDB.

In a future PR, MS-SQL support is planned.

@alexandru alexandru requested a review from Copilot February 6, 2026 14:47
@alexandru
Copy link
Copy Markdown
Member Author

@codex please review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6aff97d2dd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +39 to +44
fun evolve(ex: Exception?): Evolution =
copy(
evolutions = evolutions + 1,
retriesRemaining = retriesRemaining?.let { maxOf(it - 1, 0) },
delay = min(delay.multipliedBy(config.backoffFactor.toLong()), config.maxDelay),
thrownExceptions = ex?.let { listOf(it) + thrownExceptions } ?: thrownExceptions,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve fractional backoff factors when evolving delay

The retry config explicitly allows non-integer backoffFactor values (e.g., 1.5), but the delay evolution truncates it via toLong(). That makes any factor between 1.0 and 1.999 behave as 1, so delays never grow and retries can become much more aggressive than configured (and never reach maxDelay as expected). This affects any caller using fractional backoff values and can increase load or contention during transient failures. Consider multiplying by the double factor instead of truncating it.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces JDBC-based DelayedQueue support with HSQLDB as the first database backend. The implementation includes comprehensive retry logic, exception handling, database migrations, and vendor-specific SQL adapters. The PR also transitions from SQLException to ResourceUnavailableException in public APIs for better abstraction.

Changes:

  • Adds DelayedQueueJDBC with HSQLDB support, including SQL vendor adapters, exception filters, and retry mechanisms
  • Introduces ResourceUnavailableException as a checked exception replacing SQLException in public APIs
  • Adds RetryConfig for configuring exponential backoff retry logic
  • Updates all tests from SQLite references to HSQLDB (though SQLite driver still exists in the enum for future use)

Reviewed changes

Copilot reviewed 41 out of 41 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
gradle/libs.versions.toml Adds HSQLDB JDBC driver dependency
delayedqueue-jvm/src/main/kotlin/org/funfix/delayedqueue/jvm/DelayedQueueJDBC.kt Main JDBC implementation with retry logic and optimistic locking
delayedqueue-jvm/src/main/kotlin/org/funfix/delayedqueue/jvm/internals/jdbc/SQLVendorAdapter.kt Database-specific SQL query generation with parameterized statements
delayedqueue-jvm/src/main/kotlin/org/funfix/delayedqueue/jvm/internals/jdbc/HSQLDBMigrations.kt HSQLDB schema migrations with indexes
delayedqueue-jvm/src/main/kotlin/org/funfix/delayedqueue/jvm/internals/jdbc/SqlExceptionFilters.kt Exception classification for retry logic
delayedqueue-jvm/src/main/kotlin/org/funfix/delayedqueue/jvm/RetryConfig.kt Retry configuration with exponential backoff
delayedqueue-jvm/src/main/kotlin/org/funfix/delayedqueue/jvm/JdbcDriver.kt Adds HSQLDB to driver enum
delayedqueue-jvm/src/main/kotlin/org/funfix/delayedqueue/jvm/DelayedQueue.kt Updates exception declarations from SQLException to ResourceUnavailableException
delayedqueue-jvm/src/main/kotlin/org/funfix/delayedqueue/jvm/CronConfigHash.kt Fixes hash generation to match Scala format with leading newlines
delayedqueue-jvm/src/main/kotlin/org/funfix/delayedqueue/jvm/CronDailySchedule.kt Ensures getNextTimes always returns at least one time
delayedqueue-jvm/src/main/kotlin/org/funfix/delayedqueue/jvm/internals/utils/raise.kt Renames sneakyRaises to unsafeSneakyRaises with extensive documentation
Test files (Java) Comprehensive API contract tests using HSQLDB
Test files (Kotlin) Internal implementation tests for retry logic, exception filters
AGENTS.md Adds guidelines about following original implementations and testing conventions

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@alexandru alexandru changed the title HSQL Support DelayedQueueJDBC with initial HSQL Support Feb 6, 2026
@alexandru
Copy link
Copy Markdown
Member Author

@copilot review this PR from the perspective of exporting a stable API targeting Java projects and Java developers.

Are there code-related problems? Are any best practices violated (as outlined in AGENTS.md or in the installed kotlin-java-library skill)?

Have a look at delayedqueue-jvm/api/delayedqueue-jvm.api. Do you see anything in there that may cause binary backwards compatibility issues in the future?

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 6, 2026

@alexandru I've opened a new pull request, #3, to work on those changes. Once the pull request is ready, I'll request review from you.

@alexandru alexandru merged commit f2bdafa into main Feb 6, 2026
3 of 4 checks passed
@alexandru alexandru deleted the retries branch February 6, 2026 17:53
Copilot AI added a commit that referenced this pull request Feb 7, 2026
Add 'id' column to KindPlusScheduledAtIndex in all database migrations
to ensure ORDER BY (scheduledAt, id) queries are fully index-covered.

Also add migration #2 to update existing databases by dropping and
recreating the index with the additional column.

This ensures both deterministic ordering and optimal query performance
without requiring additional sort operations.

Co-authored-by: alexandru <11753+alexandru@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants