Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-38737: [Java] Fix JDBC caching of SqlInfo values #38739

Merged
merged 1 commit into from
Nov 16, 2023

Conversation

jduo
Copy link
Member

@jduo jduo commented Nov 15, 2023

Rationale for this change

The cache of SqlInfo properties that ArrowDatabaseMetaData maintains isn't populated in a thread-safe way. This can cause JDBC applications trying to retrieve several properties from DatabaseMetaData to encounter missing properties when they shouldn't.

What changes are included in this PR?

  • Changed the checking for the cache being populated to be based on an AtomicBoolean marking that the cache is fully populated, rather than just checking if the cache is empty.
  • Avoid having multiple threads call getSqlInfo() if they see that the cache is empty concurrently.

Are these changes tested?

Verified existing unit tests.

Are there any user-facing changes?

No.

Fix the thread-safety of DatabaseMetaData functions.
The cache of SqlInfo properties wasn't being populated in
a thread-safe manner.
@jduo jduo requested a review from lidavidm as a code owner November 15, 2023 20:56
Copy link

⚠️ GitHub issue #38737 has been automatically assigned in GitHub to PR creator.

@github-actions github-actions bot added awaiting merge Awaiting merge and removed awaiting review Awaiting review labels Nov 15, 2023
@lidavidm lidavidm merged commit 5583dbe into apache:main Nov 16, 2023
15 checks passed
@lidavidm lidavidm removed the awaiting merge Awaiting merge label Nov 16, 2023
Copy link

After merging your PR, Conbench analyzed the 5 benchmarking runs that have been run so far on merge-commit 5583dbe.

There were no benchmark performance regressions. 🎉

The full Conbench report has more details. It also includes information about 4 possible false positives for unstable benchmarks that are known to sometimes produce them.

dgreiss pushed a commit to dgreiss/arrow that referenced this pull request Feb 19, 2024
### Rationale for this change
The cache of SqlInfo properties that ArrowDatabaseMetaData maintains isn't populated in a thread-safe way. This can cause JDBC applications trying to retrieve several properties from DatabaseMetaData to encounter missing properties when they shouldn't.

### What changes are included in this PR?
- Changed the checking for the cache being populated to be based on an AtomicBoolean marking that the cache is fully populated, rather than just checking if the cache is empty.
- Avoid having multiple threads call getSqlInfo() if they see that the cache is empty concurrently.

### Are these changes tested?
Verified existing unit tests.

### Are there any user-facing changes?
No.
* Closes: apache#38737

Authored-by: James Duong <james.duong@improving.com>
Signed-off-by: David Li <li.davidm96@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Java] FlightSQL JDBC DatabaseMetaData cache isn't thread-safe
2 participants