apache / apache/iceberg

Open-API: RESTCatalogServer.stop() leaks the backend catalog

Open Beginner friendly
#17,232 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
9.2k
Forks
3.5k
Avg merge
2d 11h
Merged PRs (30d)
132

Description

**Apache Iceberg version**
main @ 3038fde68

**Query engine**
N/A — engine-agnostic test fixture

**Please describe the bug**
`RESTCatalogServer.stop()` only stops the Jetty `httpServer`; the backend `Catalog` created in `initializeBackendCatalog()` (a `Closeable` `JdbcCatalog` by default, holding a JDBC connection pool and `FileIO`) is never closed.
Offending code: `RESTCatalogServer.stop()` (`open-api/src/testFixtures/java/org/apache/iceberg/rest/RESTCatalogServer.java` line 137-141).
`RESTCatalogAdapter.close()` (`core/src/test/java/org/apache/iceberg/rest/RESTCatalogAdapter.java` line 680-685) documents that "the calling test is responsible for closing the underlying catalog" — the server is that owner but does not do it.

**Steps to reproduce**
1. Call `new RESTCatalogServer(config).start(false)`.
2. Call `server.stop()`.
3. The backend `JdbcCatalog`'s JDBC connection pool and `FileIO` are still open.

Expected: backend catalog is closed along with the server.
Actual: backend catalog resources leak.

`RESTServerExtension` (used as a class-level JUnit extension in the REST Compatibility Kit suite and in Spark 3.5/4.0/4.1 `TestBaseWithCatalog`) triggers this on every test class teardown.

**Additional context**
N/A.

Contributor guide

Open the contributing guide

Research direction

Start in open-api/src/testFixtures/java/org/apache/iceberg/rest/RESTCatalogServer.java, reading initializeBackendCatalog() and stop() to trace ownership of the backend Catalog. Check core/src/test/java/org/apache/iceberg/rest/RESTCatalogAdapter.java for the closing contract, then run the REST Compatibility Kit tests; done means server shutdown also closes the backend catalog and its resources.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend, testing
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
82/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.