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

Queries on a newly created database fail if that is the first and only attachment [JDBC190] #238

Closed
firebird-automations opened this issue Sep 24, 2011 · 10 comments

Comments

@firebird-automations
Copy link

Submitted by: @mrotteveel

Is related to JDBC185

In JDBC185 a number of tests in org.firebirdsql.gds.impl.wire.TestGds failed under Java 7, as the execution order was changed. This same test failure is reproducible if the affected tests are executed in isolation on Java 6.

The error produced by the failing tests is:
org.firebirdsql.gds.GDSException: SQLDA missing or incorrect version, or incorrect number/type of variables
at org.firebirdsql.gds.impl.wire.AbstractJavaGDSImpl.parseTruncSqlInfo(AbstractJavaGDSImpl.java:2633)
at org.firebirdsql.gds.impl.wire.AbstractJavaGDSImpl.parseSqlInfo(AbstractJavaGDSImpl.java:2468)
at org.firebirdsql.gds.impl.wire.AbstractJavaGDSImpl.iscDsqlPrepare(AbstractJavaGDSImpl.java:1604)
at org.firebirdsql.gds.impl.wire.AbstractJavaGDSImpl.iscDsqlPrepare(AbstractJavaGDSImpl.java:1559)
at org.firebirdsql.gds.impl.wire.AbstractJavaGDSImpl.iscDsqlPrepare(AbstractJavaGDSImpl.java:1551)
at org.firebirdsql.gds.impl.wire.TestGds.testCreateAndWriteBlobStreamInSegmentedPieces(TestGds.java:713)

I have identified that the following tests fail (with the same error) when run independently:
* testPreparedSelect
* testCreateAndWriteBlob
* testCreateAndWriteBlobStream
* testCreateAndWriteBlobStreamInSegmentedPieces

If these tests are preceded by any one of the following tests it does work:
* testCreateDropDB
* testCreateDropD3DB
* testDbHandleEquality

The difference seems to be that the failing tests only call iscCreateDatabase and use the database handle, while the other tests also close the database handle from the create, and then create a new attachment by calling iscAttachDatabase. Looking over the code it seems that iscCreateDatabase and iscAttachDatabase could (and should) share the same code (except for sending op_create instead of op_attach).

In iscAttachDatabase, based on the version of the connected database, infobuffers are set for iscDsqlPrepare and iscDescribe / iscDescribeBind. These buffers are set as instance variables of AbstractJavaGDSImpl. This has two problems :
1) If iscCreateDatabase is called these are not set, so results of PreparedStatements and such fail
2) As AbstractJavaGDSImpl is a 'sort-of' Singleton the values of the infobuffers set by the last call to iscAttachDatabase are used for all connections; this can be especially problematic when connecting to both Firebird 1.5 and Firebird 2.x databases.

Solution:
Make sure iscCreateDatabase and iscAttachDatabase share the same implementation, the infobuffers either need to be decided on dynamically (based on the implementation version of the db attachment), or these infobuffers should be made member variables of isc_db_handle_impl.

Commits: c79c562

@firebird-automations
Copy link
Author

Modified by: @mrotteveel

assignee: Roman Rokytskyy [ rrokytskyy ] => Mark Rotteveel [ avalanche1979 ]

@firebird-automations
Copy link
Author

Modified by: @mrotteveel

status: Open [ 1 ] => In Progress [ 3 ]

@firebird-automations
Copy link
Author

Modified by: @mrotteveel

Link: This issue is related to JDBC185 [ JDBC185 ]

@firebird-automations
Copy link
Author

Modified by: @mrotteveel

description: In JDBC185 a number of tests in org.firebirdsql.gds.impl.wire.TestGds failed under Java 7, as the execution order was changed. This same test failure is reproducible if the affected tests are executed in isolation on Java 6.

I have identified that the following tests fail (with the same error) when run independently:
* testPreparedSelect
* testCreateAndWriteBlob
* testCreateAndWriteBlobStream
* testCreateAndWriteBlobStreamInSegmentedPieces

If these tests are preceded by any one of the following tests it does work:
* testCreateDropDB
* testCreateDropD3DB
* testDbHandleEquality

The difference seems to be that the failing tests only call iscCreateDatabase and use the database handle, while the other tests also call iscAttachDatabase. Looking over the code it seems that iscCreateDatabase and iscAttachDatabase could (and should) share the same code (except for sending op_create instead of op_attach).

In iscAttachDatabase, based on the version of the connected database, infobuffers are set for iscDsqlPrepare and iscDescribe / iscDescribeBind. These buffers are set as instance variables of AbstractJavaGDSImpl. This has two problems :
1) If iscCreateDatabase is called these are not set, so results of PreparedStatements and such fail
2) As AbstractJavaGDSImpl is a 'sort-of' Singleton the values of the infobuffers set by the last call to iscAttachDatabase are used for all connections; this can be especially problematic when connecting to both Firebird 1.5 and Firebird 2.x databases.

Solution:
Make sure iscCreateDatabase and iscAttachDatabase share the same implementation, the infobuffers either need to be decided on dynamically (based on the implementation version of the db attachment), or these infobuffers should be made member variables of isc_db_handle_impl.

=>

In JDBC185 a number of tests in org.firebirdsql.gds.impl.wire.TestGds failed under Java 7, as the execution order was changed. This same test failure is reproducible if the affected tests are executed in isolation on Java 6.

The error produced by the failing tests is:
org.firebirdsql.gds.GDSException: SQLDA missing or incorrect version, or incorrect number/type of variables
at org.firebirdsql.gds.impl.wire.AbstractJavaGDSImpl.parseTruncSqlInfo(AbstractJavaGDSImpl.java:2633)
at org.firebirdsql.gds.impl.wire.AbstractJavaGDSImpl.parseSqlInfo(AbstractJavaGDSImpl.java:2468)
at org.firebirdsql.gds.impl.wire.AbstractJavaGDSImpl.iscDsqlPrepare(AbstractJavaGDSImpl.java:1604)
at org.firebirdsql.gds.impl.wire.AbstractJavaGDSImpl.iscDsqlPrepare(AbstractJavaGDSImpl.java:1559)
at org.firebirdsql.gds.impl.wire.AbstractJavaGDSImpl.iscDsqlPrepare(AbstractJavaGDSImpl.java:1551)
at org.firebirdsql.gds.impl.wire.TestGds.testCreateAndWriteBlobStreamInSegmentedPieces(TestGds.java:713)

I have identified that the following tests fail (with the same error) when run independently:
* testPreparedSelect
* testCreateAndWriteBlob
* testCreateAndWriteBlobStream
* testCreateAndWriteBlobStreamInSegmentedPieces

If these tests are preceded by any one of the following tests it does work:
* testCreateDropDB
* testCreateDropD3DB
* testDbHandleEquality

The difference seems to be that the failing tests only call iscCreateDatabase and use the database handle, while the other tests also call iscAttachDatabase. Looking over the code it seems that iscCreateDatabase and iscAttachDatabase could (and should) share the same code (except for sending op_create instead of op_attach).

In iscAttachDatabase, based on the version of the connected database, infobuffers are set for iscDsqlPrepare and iscDescribe / iscDescribeBind. These buffers are set as instance variables of AbstractJavaGDSImpl. This has two problems :
1) If iscCreateDatabase is called these are not set, so results of PreparedStatements and such fail
2) As AbstractJavaGDSImpl is a 'sort-of' Singleton the values of the infobuffers set by the last call to iscAttachDatabase are used for all connections; this can be especially problematic when connecting to both Firebird 1.5 and Firebird 2.x databases.

Solution:
Make sure iscCreateDatabase and iscAttachDatabase share the same implementation, the infobuffers either need to be decided on dynamically (based on the implementation version of the db attachment), or these infobuffers should be made member variables of isc_db_handle_impl.

@firebird-automations
Copy link
Author

Modified by: @mrotteveel

description: In JDBC185 a number of tests in org.firebirdsql.gds.impl.wire.TestGds failed under Java 7, as the execution order was changed. This same test failure is reproducible if the affected tests are executed in isolation on Java 6.

The error produced by the failing tests is:
org.firebirdsql.gds.GDSException: SQLDA missing or incorrect version, or incorrect number/type of variables
at org.firebirdsql.gds.impl.wire.AbstractJavaGDSImpl.parseTruncSqlInfo(AbstractJavaGDSImpl.java:2633)
at org.firebirdsql.gds.impl.wire.AbstractJavaGDSImpl.parseSqlInfo(AbstractJavaGDSImpl.java:2468)
at org.firebirdsql.gds.impl.wire.AbstractJavaGDSImpl.iscDsqlPrepare(AbstractJavaGDSImpl.java:1604)
at org.firebirdsql.gds.impl.wire.AbstractJavaGDSImpl.iscDsqlPrepare(AbstractJavaGDSImpl.java:1559)
at org.firebirdsql.gds.impl.wire.AbstractJavaGDSImpl.iscDsqlPrepare(AbstractJavaGDSImpl.java:1551)
at org.firebirdsql.gds.impl.wire.TestGds.testCreateAndWriteBlobStreamInSegmentedPieces(TestGds.java:713)

I have identified that the following tests fail (with the same error) when run independently:
* testPreparedSelect
* testCreateAndWriteBlob
* testCreateAndWriteBlobStream
* testCreateAndWriteBlobStreamInSegmentedPieces

If these tests are preceded by any one of the following tests it does work:
* testCreateDropDB
* testCreateDropD3DB
* testDbHandleEquality

The difference seems to be that the failing tests only call iscCreateDatabase and use the database handle, while the other tests also call iscAttachDatabase. Looking over the code it seems that iscCreateDatabase and iscAttachDatabase could (and should) share the same code (except for sending op_create instead of op_attach).

In iscAttachDatabase, based on the version of the connected database, infobuffers are set for iscDsqlPrepare and iscDescribe / iscDescribeBind. These buffers are set as instance variables of AbstractJavaGDSImpl. This has two problems :
1) If iscCreateDatabase is called these are not set, so results of PreparedStatements and such fail
2) As AbstractJavaGDSImpl is a 'sort-of' Singleton the values of the infobuffers set by the last call to iscAttachDatabase are used for all connections; this can be especially problematic when connecting to both Firebird 1.5 and Firebird 2.x databases.

Solution:
Make sure iscCreateDatabase and iscAttachDatabase share the same implementation, the infobuffers either need to be decided on dynamically (based on the implementation version of the db attachment), or these infobuffers should be made member variables of isc_db_handle_impl.

=>

In JDBC185 a number of tests in org.firebirdsql.gds.impl.wire.TestGds failed under Java 7, as the execution order was changed. This same test failure is reproducible if the affected tests are executed in isolation on Java 6.

The error produced by the failing tests is:
org.firebirdsql.gds.GDSException: SQLDA missing or incorrect version, or incorrect number/type of variables
at org.firebirdsql.gds.impl.wire.AbstractJavaGDSImpl.parseTruncSqlInfo(AbstractJavaGDSImpl.java:2633)
at org.firebirdsql.gds.impl.wire.AbstractJavaGDSImpl.parseSqlInfo(AbstractJavaGDSImpl.java:2468)
at org.firebirdsql.gds.impl.wire.AbstractJavaGDSImpl.iscDsqlPrepare(AbstractJavaGDSImpl.java:1604)
at org.firebirdsql.gds.impl.wire.AbstractJavaGDSImpl.iscDsqlPrepare(AbstractJavaGDSImpl.java:1559)
at org.firebirdsql.gds.impl.wire.AbstractJavaGDSImpl.iscDsqlPrepare(AbstractJavaGDSImpl.java:1551)
at org.firebirdsql.gds.impl.wire.TestGds.testCreateAndWriteBlobStreamInSegmentedPieces(TestGds.java:713)

I have identified that the following tests fail (with the same error) when run independently:
* testPreparedSelect
* testCreateAndWriteBlob
* testCreateAndWriteBlobStream
* testCreateAndWriteBlobStreamInSegmentedPieces

If these tests are preceded by any one of the following tests it does work:
* testCreateDropDB
* testCreateDropD3DB
* testDbHandleEquality

The difference seems to be that the failing tests only call iscCreateDatabase and use the database handle, while the other tests also close the database handle from the create, and then create a new attachment by calling iscAttachDatabase. Looking over the code it seems that iscCreateDatabase and iscAttachDatabase could (and should) share the same code (except for sending op_create instead of op_attach).

In iscAttachDatabase, based on the version of the connected database, infobuffers are set for iscDsqlPrepare and iscDescribe / iscDescribeBind. These buffers are set as instance variables of AbstractJavaGDSImpl. This has two problems :
1) If iscCreateDatabase is called these are not set, so results of PreparedStatements and such fail
2) As AbstractJavaGDSImpl is a 'sort-of' Singleton the values of the infobuffers set by the last call to iscAttachDatabase are used for all connections; this can be especially problematic when connecting to both Firebird 1.5 and Firebird 2.x databases.

Solution:
Make sure iscCreateDatabase and iscAttachDatabase share the same implementation, the infobuffers either need to be decided on dynamically (based on the implementation version of the db attachment), or these infobuffers should be made member variables of isc_db_handle_impl.

@firebird-automations
Copy link
Author

Commented by: @mrotteveel

Initially implementation using dynamic decision in my workspace. Contemplating to change this to member variables.

@firebird-automations
Copy link
Author

Modified by: @mrotteveel

Fix Version: Jaybird 2.2 [ 10053 ]

@firebird-automations
Copy link
Author

Commented by: @mrotteveel

Decided to keep the dynamic decision; in the future we might want to restructure the wire protocol implementation to make it more OO and less procedural.

@firebird-automations
Copy link
Author

Modified by: @mrotteveel

status: In Progress [ 3 ] => 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