liquibase / liquibase

Main Liquibase Source
https://www.liquibase.org
Apache License 2.0
4.53k stars 1.81k forks source link

Unclosed `PreparedStatement` when closing `Liquibase` instance (when using `loadData`) #3128

Open famod opened 1 year ago

famod commented 1 year ago

Environment

Liquibase Version: 4.13.0

Liquibase Integration & Version: Quarkus 2.11.1.Final

Liquibase Extension(s) & Version: -

Database Vendor & Version: MariaDB 10.6.8

Operating System Type & Version: not relevant

Infrastructure Type/Provider: not relevant

Description

2914 introduced a PreparedStatement leak, apparently on purpose: https://github.com/liquibase/liquibase/pull/2914/files#diff-b378dd1eeb35b9dbe8751bd7462c9aad1b1c8c74d6cd5fd6c64b4014d05a1260R53

This is highly questionable in environments that report such leaks, e.g. Quarkus with Agroal (actually not a good practice at all, IMO):

WARN  [io.agr.pool] (main) Datasource '<default>': JDBC resources leaked: 0 ResultSet(s) and 1 Statement(s)

Steps To Reproduce

Should be pretty obvious but if required I can adjust the Quarkus liquibase-quickstart.

Actual Behavior

Statement is not closed when Liquibase instance is closed.

Expected/Desired Behavior

All "resources", including any PreparedStatements etc., are properly closed when closing the Liquibase instance.

Screenshots (if appropriate)

n/a

Additional Context

https://github.com/quarkusio/quarkus/issues/26995

famod commented 1 year ago

To be more precise:

This is highly questionable in environments that report such leaks

Agroal in Quarkus actually auto-closes the Statement after issuing the warning, so it shields the user from actual leaks piling up. So in fact this issue is more severe in environments that do not offer such a safeguard! The warning in Quarkus is annoying still.