Skip to content
This repository was archived by the owner on Mar 23, 2018. It is now read-only.
This repository was archived by the owner on Mar 23, 2018. It is now read-only.

Fairly serious thread-safety issues #7

@brettwooldridge

Description

@brettwooldridge

I plugged your pool into the HikariCP benchmark harness because I was curious how DBPool performed. The benchmark uses Oracle's JMH benchmarking framework, and the primary connection test simply performs DataSource.getConnection() then connection.close() in multiple threads, as fast as possible.

Unfortunately, DBPool blows-up within the first few milliseconds. Because the open and closing members of CacheConnection are not volatile there are quickly cross-thread visibility issues (exceptions) that cause the connection to be declared invalid almost immediately and ejected from the pool.

I note also the complete lack of unit tests for this library, which should have quickly uncovered this issue. Applications that are using DBPool are either not under significant load or are "getting lucky" by crossing a Java memory barrier that happens to flush the CPU cache-lines before cross-thread visibility issues arise.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions