JDBC bugfix: Don't reuse a defunct databaseMetaData#2660
JDBC bugfix: Don't reuse a defunct databaseMetaData#2660michael-berlin merged 2 commits intovitessio:masterfrom
Conversation
b0e52c7 to
18166e2
Compare
18166e2 to
eebd543
Compare
|
The reason why we made the databaseMetadata as static is because we didn't want to fire the show queries for every connection. Review status: 0 of 1 files reviewed at latest revision, 1 unresolved discussion, some commit checks broke. java/jdbc/src/main/java/com/flipkart/vitess/jdbc/VitessConnection.java, line 235 at r1 (raw file):
Please rename this function to metadataNullOrDefunctional(). Comments from Reviewable |
|
Just a Minor Comment, Rest Looks Good to Me. |
|
Thanks! Defunctional is not a word, so I renamed to Closed instead -- |
|
Reviewed 1 of 1 files at r1. Comments from Reviewable |
|
Thank you so much for fixing it. Review status: 0 of 1 files reviewed at latest revision, 1 unresolved discussion. Comments from Reviewable |
|
@sougou @alainjobart @michael-berlin This got a LGTM. Could one of you merge when you get a chance? Looking to submit a dependent PR today. Thanks! |
I'm not sure why databaseMetaData is a static variable. It looks to have been that way since the very beginning. But I recently ran into an issue where if you create multiple VitessConnections and close the first one, all of the other VitessConnections reference what is effectively a defunct databaseMetadata. That is, the databaseMetadata references a connection which is closed, and so nothing can be called on it.
This is very easily reproducible for anyone who uses hikari or other jdbc pooling libraries.
This fixes to ensure we don't re-use such databaseMetadata values. I'd also be happy to make this non-static, if preferred.
@harshit-gangal @ashudeep-sharma