Skip to content

bug(jdbc): async driver downloads keep the JVM alive and expose partial jars #2684

Description

@HandSonic

Chat2DB Edition

Chat2DB Community

Chat2DB Version

main at 2442df9

Deployment

Web, Desktop, and embedded backend

Operating System

Any

Problem Summary

JdbcJarUtils configures the asynchronous OkHttp Dispatcher with Executors.newFixedThreadPool(20). The default thread factory creates non-daemon workers and the static executor is never shut down, so the first asynchronous driver download can keep the JVM alive after the application context closes. Downloads also write directly to the final jar path, which makes an interrupted process expose a partial driver file.

Steps to Reproduce

  1. Remove a startup JDBC driver jar so JarDownloadTask triggers JdbcJarUtils.asyncDownload.
  2. Let the asynchronous request start or complete.
  3. Close the Spring or embedded application context without calling System.exit.
  4. Observe the JVM process and the driver directory during an interrupted download.

Expected Behavior

Download workers do not prevent normal JVM shutdown, and only complete driver jars are published at their final paths.

Actual Behavior

Up to 20 non-daemon fixed-pool workers remain alive indefinitely. A forced shutdown can also leave a truncated file at the final jar path, and the next startup may treat its existence as a completed download.

Logs

No error is required; the worker threads wait on the executor queue after the request completes.

Screenshots or Additional Context

The executor is static, core threads do not time out, and no shutdown path exists. Any daemon-thread fix must publish through a temporary file before atomically replacing the final jar to avoid making interrupted downloads visible.

Impact

Natural shutdown can hang in tests, embedded use, or controlled application exits. Interrupted downloads can leave an unusable JDBC driver cached across restarts.

Workaround

Force-terminate the JVM and manually delete any truncated driver jar before restarting.

Submission Checklist

  • Reproduced on the selected Chat2DB edition.
  • Searched existing issues and pull requests for duplicates.
  • Removed credentials and private data.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status
    In Review

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions