Liquibase and JDBC driver cancellation: should interrupted changeSets clear the interrupt flag or propagate it?
0 reputation · 11 Jun 2020, 01:01 UTC
0 reputation · 11 Jun 2020, 01:01 UTC
I am integrating Liquibase update execution into a service that manages its own worker threads and cancellation lifecycle. The integration boundary in question is between Liquibase's changeSet executor and the underlying JDBC driver: when a long-running changeSet is cancelled via Thread.interrupt, Liquibase attempts Statement.cancel() if the driver supports it, and otherwise lets the thread exit with InterruptedException.
The uncertainty is driver-dependent behavior and interrupt-flag ownership. PostgreSQL implements cancel() via a CancelRequest message, while MySQL Connector/J may ignore it or throw UnsupportedOperationException, so the same cancellation request produces different latency and exception types per driver. Separately, query timeouts set via Statement.setQueryTimeout surface as driver-specific SQLExceptions that Liquibase treats as changeSet failures, but there is no unified Liquibase configuration to choose between interrupt-based cancellation and timeout-based termination. Assume Liquibase 4.x with recent PostgreSQL and MySQL drivers.
My questions:
InterruptedException during a cancelled changeSet, is the thread's interrupted status preserved for the calling framework, or cleared? Is this documented or driver-dependent?A thoughtful contribution can make all the difference. Be the first to share one.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.