You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by "PDGGK (via GitHub)" <gi...@apache.org> on 2026/08/10 16:11:21 UTC
[I] [Bug][Connector-V2][Neo4j] Session and driver are leaked when the final flush or session close fails [seatunnel]
PDGGK opened a new issue, #11749:
URL: https://github.com/apache/seatunnel/issues/11749
### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/seatunnel/issues?q=is%3Aissue+label%3A%22bug%22) and found no similar issues.
### What happened
`Neo4jSinkWriter.close()` and `Neo4jSourceReader.close()` both release the session and the driver as consecutive statements, so anything that throws part way through leaks the rest.
The sink is the sharper case, because `close()` flushes the last batch first:
```java
// Neo4jSinkWriter.java:144
public void close() throws IOException {
flushWriteBuffer();
session.close();
driver.close();
}
```
`flushWriteBuffer()` → `writeByQuery()` deliberately converts a `Neo4jException` into a `Neo4jConnectorException` and rethrows it (`Neo4jSinkWriter.java:129-132`). So whenever the final batch fails to write — the database going away during teardown is the ordinary case — neither `session.close()` nor `driver.close()` runs, and the whole `Driver` is leaked along with its connection pool and Netty event-loop group.
`Neo4jSourceReader.close()` has the same shape without the flush:
```java
// Neo4jSourceReader.java:73
public void close() throws IOException {
session.close();
driver.close();
}
```
If `session.close()` throws, the driver is leaked.
### SeaTunnel Version
dev
### SeaTunnel Config
Any Neo4j sink; the leak happens at teardown, not in the pipeline definition.
### Running Command
n/a
### Error Exception
No exception is reported for the leak itself — the `Neo4jConnectorException` from the failed flush is what surfaces, and the leaked driver is silent.
### Zeta or Flink or Spark Version
n/a
### Java or Scala Version
n/a
### Screenshots
n/a
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Bug][Connector-V2][Neo4j] Session and driver are leaked when the final flush or session close fails [seatunnel]
Posted by "davidzollo (via GitHub)" <gi...@apache.org>.
davidzollo closed issue #11749: [Bug][Connector-V2][Neo4j] Session and driver are leaked when the final flush or session close fails
URL: https://github.com/apache/seatunnel/issues/11749
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Bug][Connector-V2][Neo4j] Session and driver are leaked when the final flush or session close fails [seatunnel]
Posted by "PDGGK (via GitHub)" <gi...@apache.org>.
PDGGK commented on issue #11749:
URL: https://github.com/apache/seatunnel/issues/11749#issuecomment-5247939912
Review feedback addressed in 477b2d0 on #11750 — the close paths now preserve the first failure and attach later ones as suppressed, following the `appendSuppressed`/`rethrowCloseFailure` pattern already used in `connector-pulsar`. Details and the regression-coverage table are on the PR.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Bug][Connector-V2][Neo4j] Session and driver are leaked when the final flush or session close fails [seatunnel]
Posted by "DanielLeens (via GitHub)" <gi...@apache.org>.
DanielLeens commented on issue #11749:
URL: https://github.com/apache/seatunnel/issues/11749#issuecomment-5247866937
Thanks for writing this up with the exact close path.
I checked the current Neo4j connector code, and this is a real resource-release bug. In the sink, `close()` still executes `flushWriteBuffer() -> session.close() -> driver.close()` as plain sequential calls, so any exception from the final flush prevents both the session and the driver from being closed. The source reader has the same shape: if `session.close()` throws, `driver.close()` is skipped.
That means this is not only a one-off teardown annoyance: it can leak the driver's connection pool and background resources precisely on the failure path where cleanup matters most.
A good fix here would be to make both close paths best-effort and exception-safe:
- always attempt to close both session and driver;
- preserve the primary failure from flush / close;
- attach later cleanup failures as suppressed exceptions instead of losing the original cause.
Please also cover both sink and source sides together, with a regression test that proves the second resource is still closed when the first step fails.
You marked that you are willing to submit the PR. I also tried to assign the issue accordingly, but GitHub did not accept the assignee update from my side, so please continue on the PR path and we can keep tracking progress here.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org