Hi!
I have a nasty bug in my application, but I can’t reproduce it intentionally so far, though it appears quite often.
My environment: SmartGWTEE 2.5 nightly build 2011-09-02, Java 6, GWT 2.3.0, PostgreSQL 9, Tomcat 6.
I know I need to post my stack trace, but first, I’ll try to explain what I’m trying to do in my code and what happens.
I have s DMI class that handles a complex SQL transaction spanning maybe a dozen various SQL operations (fetch, insert, update, delete) on several tables.
File: dnevnikDS.xml
My DMI class:
SQL operation that are called from the DMI class are standard SQL operations, without any customization, or minimal through SQL templating.
My server.properties:
So, my basic assumption is that all SQL operations called from my DMI class should be executed in the SINGLE TRANSACTION, considering that I have set sql.PostgreSQL.autoJoinTransactions to ALL.
And that happens... almost every time.
In some weird situations (especially when my customers test), this one scenario happens (as I can see from the log):
- the first 2 SQL operations get executed successfully
- something happens that causes that current transaction gets commited
- I conclude from the log that the next SQL operation in the DMI doesn’t succeed because there is no open connection and I receive IOException: Stream closed from PostgreSQL JDBC driver because I’m obviously trying to execute a statement against a stale or closed connection
As a result, I my transaction gets PARTLY EXECUTED, so it is not a transaction anymore.
I will continue trying to reproduce the bug, but right now I wonder if I have misunderstood some basic concept here.
I know you need my stacktrace, but it would take to much time to extract confidential information from it, so please provide an e-mail address where I can send it to. I will send it tomorrow morning (Central European Time).
Thx.
I have a nasty bug in my application, but I can’t reproduce it intentionally so far, though it appears quite often.
My environment: SmartGWTEE 2.5 nightly build 2011-09-02, Java 6, GWT 2.3.0, PostgreSQL 9, Tomcat 6.
I know I need to post my stack trace, but first, I’ll try to explain what I’m trying to do in my code and what happens.
I have s DMI class that handles a complex SQL transaction spanning maybe a dozen various SQL operations (fetch, insert, update, delete) on several tables.
File: dnevnikDS.xml
Code:
<DataSource
dbName="PostgreSQL"
tableName="dnevnik"
ID="dnevnikDS"
serverType="sql"
autoDeriveSchema="true"
>
<fields>
<field name="dnevnik_id" type="sequence" hidden="true" primaryKey="true" sequenceName="dnevnik_dnevnik_id_seq"></field>
….
// other fields
</fields>
<operationBindings>
<operationBinding operationType="add" operationId="add_dnevnik">
<serverObject className="com.mycompany.crm.server.dmi.DnevnikDMI" methodName="addDnevnik"/>
</operationBinding>
</operationBindings>
Code:
package com.mycompany.crm.server.dmi;
public class DnevnikDMI {
public DSResponse addDnevnik(DSRequest dsRequest) throws Exception {
DSResponse dsResponse = dsRequest.execute();
if (dsResponse.statusIsError()) {
return dsResponse;
}
DSRequest req2 = new DSRequest("anotherDS", "update", dsRequest.getRPCManager());
Map<String, Object> m2 = new HashMap<String, Object>();
m2.put("some_field", values.get("some_field));
req2.setValues(m2);
req2.setCriteria("some_field", “something”);
DSResponse res2 = req2.execute();
if (res2.statusIsError()) {
return res2;
}
// several SQL operations
DSRequest req5 = new DSRequest("yetAnotherDS", "update", dsRequest.getRPCManager());
Map<String, Object> m5 = new HashMap<String, Object>();
m5.put("some_field", values.get("some_field));
req5.setValues(m5);
req5.setCriteria("some_field", “something”);
DSResponse res5 = req5.execute();
if (res5.statusIsError()) {
return res5;
}
return res;
}
My server.properties:
Code:
sql.defaultDatabase: PostgreSQL sql.PostgreSQL.autoJoinTransactions: ALL sql.PostgreSQL.interface.credentialsInURL: false sql.PostgreSQL.driver.context: _container_ sql.PostgreSQL.driver.portNumber: 5432 sql.PostgreSQL.driver: org.postgresql.Driver sql.PostgreSQL.driver.password: secret sql.PostgreSQL.driver.driverName: postgresql sql.PostgreSQL.driver.networkProtocol: tcp sql.PostgreSQL.interface.type: driverManager sql.PostgreSQL.driver.serverName: localhost sql.PostgreSQL.database.type: postgresql sql.PostgreSQL.driver.databaseName: my_db sql.PostgreSQL.driver.name: PostgreSQL sql.PostgreSQL.driver.driverType: thin sql.PostgreSQL.driver.user: db_user
And that happens... almost every time.
In some weird situations (especially when my customers test), this one scenario happens (as I can see from the log):
- the first 2 SQL operations get executed successfully
- something happens that causes that current transaction gets commited
- I conclude from the log that the next SQL operation in the DMI doesn’t succeed because there is no open connection and I receive IOException: Stream closed from PostgreSQL JDBC driver because I’m obviously trying to execute a statement against a stale or closed connection
As a result, I my transaction gets PARTLY EXECUTED, so it is not a transaction anymore.
I will continue trying to reproduce the bug, but right now I wonder if I have misunderstood some basic concept here.
I know you need my stacktrace, but it would take to much time to extract confidential information from it, so please provide an e-mail address where I can send it to. I will send it tomorrow morning (Central European Time).
Thx.
Comment