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

Synchronization Bug with Blob - SOLUTION [JDBC300] #346

Closed
firebird-automations opened this issue Feb 19, 2013 · 5 comments
Closed

Synchronization Bug with Blob - SOLUTION [JDBC300] #346

firebird-automations opened this issue Feb 19, 2013 · 5 comments

Comments

@firebird-automations
Copy link

Submitted by: Stefan Schmaltz (schlocke)

In our multi-threaded application we got errors like this:
java.lang.ArrayIndexOutOfBoundsException
Error executing sql instruction:

select * from ORDERINGS ons join USERS usr on usr.USR_ID = ons.ONS_USR_ID join ONSSUPPLIERS oss on oss.OSS_ONS_ID = ons.ONS_ID left join ADDRESSDATA ada on ada.ADA_ID = oss.OSS_ADA_ID left join SUPPL
IER sup on sup.SUP_ID = oss.OSS_SUP_ID left join ADRCONTACTPERSON acp on acp.acp_id = oss.OSS_ACP_ID where ONS_TYPE=3 AND ONS_STATE=18 AND (ons.ONS_DELIVERYDATEGIV is not NULL or ons.ONS_DELIVERYDATER
EQ is not NULL )
java.lang.reflect.UndeclaredThrowableException
at org.firebirdsql.jdbc.FBStatementFactory.createPreparedStatement(FBStatementFactory.java:101)
at org.firebirdsql.jdbc.AbstractConnection.prepareStatement(AbstractConnection.java:1187)
at org.firebirdsql.jdbc.AbstractConnection.prepareStatement(AbstractConnection.java:942)
at com.borland.dx.sql.dataset.Database.createPreparedStatement(Database.java:923)
at komet3.DB.Komet3Database.createPreparedStatement(Komet3Database.java:210)
at komet3.DB.entityTools.Komet3EntityProxy.loadDetailData(Komet3EntityProxy.java:905)
at komet3.DB.entityTools.Komet3EntityProxy.invoke(Komet3EntityProxy.java:582)
at komet3.DB.entities.UserGroup_$$_javassist_2.getUserGroupStartPages(UserGroup_$$_javassist_2.java)
at komet3.client.apps.start.Komet3Start.updateBrowsers(Komet3Start.java:60)
at komet3.client.apps.start.Komet3Start.<init>(Komet3Start.java:44)
at komet3.client.apps.start.Komet3Start_func.runK3(Komet3Start_func.java:74)
at komet3.client.Komet3ClientAppMainFrame.resetDesktop(Komet3ClientAppMainFrame.java:960)
at komet3.client.Komet3ClientAppMainFrame.initDesktop(Komet3ClientAppMainFrame.java:878)
at komet3.client.Komet3ClientAppMainFrame.<init>(Komet3ClientAppMainFrame.java:722)
at komet3.client.Komet3ClientApp.<init>(Komet3ClientApp.java:101)
at komet3.client.Komet3ClientApp$1.run(Komet3ClientApp.java:245)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:727)
at java.awt.EventQueue.access$200(EventQueue.java:103)
at java.awt.EventQueue$3.run(EventQueue.java:688)
at java.awt.EventQueue$3.run(EventQueue.java:686)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:697)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
Caused by: java.lang.OutOfMemoryError: Requested array size exceeds VM limit
at org.firebirdsql.gds.impl.wire.AbstractJavaGDSImpl.parseTruncSqlInfo(AbstractJavaGDSImpl.java:2455)
at org.firebirdsql.gds.impl.wire.AbstractJavaGDSImpl.parseSqlInfo(AbstractJavaGDSImpl.java:2410)
at org.firebirdsql.gds.impl.wire.AbstractJavaGDSImpl.iscDsqlPrepare(AbstractJavaGDSImpl.java:1552)
at org.firebirdsql.gds.impl.GDSHelper.prepareStatement(GDSHelper.java:190)
at org.firebirdsql.jdbc.AbstractStatement.prepareFixedStatement(AbstractStatement.java:1440)
at org.firebirdsql.jdbc.AbstractPreparedStatement.prepareFixedStatement(AbstractPreparedStatement.java:1281)
at org.firebirdsql.jdbc.AbstractPreparedStatement.<init>(AbstractPreparedStatement.java:137)
at org.firebirdsql.jdbc.FBPreparedStatement.<init>(FBPreparedStatement.java:45)
at sun.reflect.GeneratedConstructorAccessor15.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
at org.firebirdsql.jdbc.FBStatementFactory.createPreparedStatement(FBStatementFactory.java:89)
at org.firebirdsql.jdbc.AbstractConnection.prepareStatement(AbstractConnection.java:1187)
at org.firebirdsql.jdbc.AbstractConnection.prepareStatement(AbstractConnection.java:942)
at com.borland.dx.sql.dataset.Database.createPreparedStatement(Database.java:923)
at komet3.DB.Komet3Database.createPreparedStatement(Komet3Database.java:210)
at komet3.DB.entityTools.Komet3EntityProxy.loadDetailData(Komet3EntityProxy.java:905)
at komet3.DB.entityTools.Komet3EntityProxy.invoke(Komet3EntityProxy.java:582)
at komet3.DB.entities.UserGroup_$$_javassist_2.getUserGroupStartPages(UserGroup_$$_javassist_2.java)
at komet3.client.apps.start.Komet3Start.updateBrowsers(Komet3Start.java:60)
at komet3.client.apps.start.Komet3Start.<init>(Komet3Start.java:44)
at komet3.client.apps.start.Komet3Start_func.runK3(Komet3Start_func.java:74)
at komet3.client.Komet3ClientAppMainFrame.resetDesktop(Komet3ClientAppMainFrame.java:960)
at komet3.client.Komet3ClientAppMainFrame.initDesktop(Komet3ClientAppMainFrame.java:878)
at komet3.client.Komet3ClientAppMainFrame.<init>(Komet3ClientAppMainFrame.java:722)
at komet3.client.Komet3ClientApp.<init>(Komet3ClientApp.java:101)
at komet3.client.Komet3ClientApp$1.run(Komet3ClientApp.java:245)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:727)
at java.awt.EventQueue.access$200(EventQueue.java:103)
at java.awt.EventQueue$3.run(EventQueue.java:688)
at java.awt.EventQueue$3.run(EventQueue.java:686)

"Caused by: java.lang.OutOfMemoryError: Requested array size exceeds VM limit"
Also many
"Negative Index" Exception
and
"Array Index out of Bounce" Exceptions

Looks like the problem happens while executing many sql instructions in threads with reading blob data.
And this is the reason: AbstractJavaGDSImpl.iscBlobInfo is not synchronized to db, only to blob

same thing with iscSeekBlob and fbCancelOperation

SOLUTION:
add synchronization to those 3 methods:

instead of
synchronized (blob) {
...

use this:

synchronized \(blob\) \{
  synchronized \(db\) \{
    try \{

....

Then all those Exception are gone!

Commits: fe8ab6e

@firebird-automations
Copy link
Author

Modified by: @mrotteveel

Fix Version: Jaybird 2.2.3 [ 10510 ]

Fix Version: Jaybird 2.3 [ 10440 ]

Version: Jaybird 3.0 [ 10441 ] =>

@firebird-automations
Copy link
Author

Modified by: @mrotteveel

Fix Version: Jaybird 2.3 [ 10440 ] =>

@firebird-automations
Copy link
Author

Commented by: @mrotteveel

The issue was already fixed in 2.3 during a cleanup of the wire protocol code. I committed the fix for 2.2.3. I will need to do some additional testing as I also fixed some of the synchronisation in the JNI implementation (also in 2.3).

Be aware though that JDBC does not actually require thread-safety (although Jaybird - usually - does provide it), and it is recommended that a single JDBC connection only be used on a single thread at a time; interleaving requests from multiple threads to the same connection is - in general - not recommended. You might want to check if you are sharing a single connection with multiple threads: I'd advise to change it so this doesn't happen.

@firebird-automations
Copy link
Author

Modified by: @mrotteveel

status: Open [ 1 ] => Resolved [ 5 ]

resolution: Fixed [ 1 ]

@firebird-automations
Copy link
Author

Modified by: @mrotteveel

status: Resolved [ 5 ] => Closed [ 6 ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment