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

MonetResultSet use of SimpleDateFormat not threadsafe #2950

Closed
monetdb-team opened this issue Nov 30, 2020 · 0 comments
Closed

MonetResultSet use of SimpleDateFormat not threadsafe #2950

monetdb-team opened this issue Nov 30, 2020 · 0 comments
Labels
bug Something isn't working Client interfaces normal

Comments

@monetdb-team
Copy link

Date: 2011-12-19 12:18:56 +0100
From: robertminer1222
To: clients devs <>
Version: 11.5.9 (Aug2011-SP3) [obsolete]

Last updated: 2012-01-26 15:32:08 +0100

Comment 16658

Date: 2011-12-19 12:18:56 +0100
From: robertminer1222

User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.121 Safari/535.2
Build Identifier:

ResultSets that need String to Date parsing, resulting from queries executed in concurrent sessions, trigger exceptions such as the one below. Possibly this is because of the use of static SimpleDateFormat variables in the MonetResultSet class, which is not thread safe.

Stack trace:

java.lang.NumberFormatException: For input string: "2000099.E2000099E44"
at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1222) ~[na:1.6.0_26]
at java.lang.Double.parseDouble(Double.java:510) ~[na:1.6.0_26]
at java.text.DigitList.getDouble(DigitList.java:151) ~[na:1.6.0_26]
at java.text.DecimalFormat.parse(DecimalFormat.java:1303) ~[na:1.6.0_26]
at java.text.SimpleDateFormat.subParse(SimpleDateFormat.java:1591) ~[na:1.6.0_26]
at java.text.SimpleDateFormat.parse(SimpleDateFormat.java:1312) ~[na:1.6.0_26]
at nl.cwi.monetdb.jdbc.MonetResultSet.getJavaDate(MonetResultSet.java:1666) ~[monetdb-jdbc-1.22.jar:na]
at nl.cwi.monetdb.jdbc.MonetResultSet.getDate(MonetResultSet.java:1788) ~[monetdb-jdbc-1.22.jar:na]
at nl.cwi.monetdb.jdbc.MonetResultSet.getDate(MonetResultSet.java:1769) ~[monetdb-jdbc-1.22.jar:na]
at nl.cwi.monetdb.jdbc.MonetResultSet.getObject(MonetResultSet.java:1376) ~[monetdb-jdbc-1.22.jar:na]
at nl.cwi.monetdb.jdbc.MonetResultSet.getObject(MonetResultSet.java:1338) ~[monetdb-jdbc-1.22.jar:na]

Reproducible: Sometimes

Comment 16659

Date: 2011-12-20 10:13:05 +0100
From: @grobian

for my understanding, are you using multiple threads on a single ResultSet, or just multiple threads on each its own ResultSet?

Comment 16662

Date: 2011-12-20 15:17:06 +0100
From: robertminer1222

Thanks for following up on this possible issue.

It's the latter: (multiple threads on each its own ResultSet: each session opens its own JDBC connection, and closes it when finished. All of the session's DB work is executed in a single thread.

Comment 16663

Date: 2011-12-20 16:00:12 +0100
From: @grobian

Thank you. For that case the simplest solution is to drop the 'static'. I guess the performance penalty incurred by that can be neglected.

Comment 16664

Date: 2011-12-20 16:09:28 +0100
From: @grobian

Changeset 5cc6927f19df made by Fabian Groffen fabian@cwi.nl in the MonetDB repo, refers to this bug.

For complete details, see http//devmonetdborg/hg/MonetDB?cmd=changeset;node=5cc6927f19df

Changeset description:

ResultSet: make date parsers instance local

It was nice for performance to share the same date parsers between all
instances of MonetResultSet, but it caused problems in concurrent use,
so better have them instance local.  With some luck, Java does lazy/jit
instantiation, which means we still don't pay if we don't use
date-related getters.  Solves bug #2950.

Comment 16665

Date: 2011-12-20 16:10:18 +0100
From: @grobian

Fix will be part of the Dec2011 feature release.

Comment 16681

Date: 2011-12-22 12:28:20 +0100
From: @grobian

If possible, could you please try the driver from
http://monetdb.cwi.nl/testweb/web/42598:ef01bf784b71/Java6/monetdb-jdbc-2.0.jar
or
http://monetdb.cwi.nl/testweb/web/42598:ef01bf784b71/Java7/monetdb-jdbc-2.0.jar
to verify if this fix is sufficient for your scenario? Thanks!

Comment 16682

Date: 2011-12-22 18:34:31 +0100
From: robertminer1222

(In reply to comment 6)

Works like a charm. Great response time, Fabian.
Thanks a lot!

Comment 16836

Date: 2012-01-26 15:32:08 +0100
From: @sjoerdmullender

The Dec2011 version has been release, so declaring this bug as FIXED.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Client interfaces normal
Projects
None yet
Development

No branches or pull requests

2 participants