Hi,
We have recently switched to the new nightly build of SmartGWT and GWT: SC_SNAPSHOT-2010-11-29/PowerEdition Deployment (built 2010-11-29) and GWT 2.1.0. As database we use mysql Ver 14.14 Distrib 5.1.50, for Win64 (unknown). Now we are encountering some weird problem in one of our DMI methods.
In our code we have some comboboxes where you can multiselect, and we process these values in a DMI method so we can insert and remove in our manytomany-table. However this approach (that used to work) doesn't work anymore.
This is some logging produced in my testcase:
I guess the opened transaction locks customer (I am far from a mysql expert) and prevents the Content import to happen (they are INNODB tables and connected with a foreign key constraint). The transaction doesnt seem to be closed.
I hope my explanation wasn't too confusing. Anyway, I have produced a small example to reproduce:
Datasources:
We have recently switched to the new nightly build of SmartGWT and GWT: SC_SNAPSHOT-2010-11-29/PowerEdition Deployment (built 2010-11-29) and GWT 2.1.0. As database we use mysql Ver 14.14 Distrib 5.1.50, for Win64 (unknown). Now we are encountering some weird problem in one of our DMI methods.
In our code we have some comboboxes where you can multiselect, and we process these values in a DMI method so we can insert and remove in our manytomany-table. However this approach (that used to work) doesn't work anymore.
This is some logging produced in my testcase:
Code:
=== 2010-12-01 16:09:35,770 [l0-6] DEBUG SQLTransaction - [builtinApplication.Customer_update] Started new transaction "1434189849" === 2010-12-01 16:09:35,770 [l0-6] INFO SQLDriver - [builtinApplication.Customer_update] Executing SQL update on 'Mysql': UPDATE Customer SET cstm_name='A Lab Inc22' WHERE (Customer.cstm_pk='1') .... .... === 2010-12-01 16:09:35,796 [l0-6] INFO SQLDriver - [builtinApplication.null] Executing SQL update on 'Mysql': INSERT INTO content (cntn_fk_customer, cntn_id) VALUES (1, 'id') === 2010-12-01 16:10:26,798 [l0-6] INFO SQLDriver - [builtinApplication.null] Execute of update: INSERT INTO content (cntn_fk_customer, cntn_id) VALUES (1, 'id') on db: Mysql threw exception: java.sql.SQLException: Lock wait timeout exceeded; try restarting transaction - assuming stale connection and retrying update. ... java.sql.SQLException: Lock wait timeout exceeded; try restarting transaction ...
I hope my explanation wasn't too confusing. Anyway, I have produced a small example to reproduce:
Code:
package test.client; import com.google.gwt.core.client.EntryPoint; import com.smartgwt.client.data.Criteria; import com.smartgwt.client.data.DataSource; import com.smartgwt.client.widgets.IButton; import com.smartgwt.client.widgets.events.ClickEvent; import com.smartgwt.client.widgets.events.ClickHandler; import com.smartgwt.client.widgets.form.DynamicForm; import com.smartgwt.client.widgets.layout.HLayout; public class LockTest implements EntryPoint { public void onModuleLoad() { DataSource ds = DataSource.get("Customer"); Criteria crit = new Criteria(); crit.addCriteria("cstm_pk", 1); final DynamicForm form = new DynamicForm(); form.setDataSource(ds); form.fetchData(crit); IButton save = new IButton("save"); save.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { form.saveData(); } }); HLayout hLayout = new HLayout(); hLayout.addMember(form); hLayout.addMember(save); hLayout.draw(); } }
Code:
package test.server; import java.util.HashMap; import java.util.Map; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; import org.springframework.stereotype.Service; import com.isomorphic.datasource.DSRequest; import com.isomorphic.datasource.DSResponse; public class DMIService { public DSResponse updateCustomer(DSRequest dsRequest, HttpServletRequest servletRequest, HttpSession session) throws Exception { DSResponse dsResponse = dsRequest.execute(); Object cstmPk = dsRequest.getValues().get("cstm_pk"); DSRequest addRequest = new DSRequest("contents", "add"); Map<String, Object> newRecord = new HashMap<String, Object>(); newRecord.put("cntn_id", "id"); newRecord.put("cntn_status", 20); newRecord.put("cntn_fk_contenttype", 1); newRecord.put("cntn_fk_customer", cstmPk); addRequest.setValues(newRecord); addRequest.setOldValues(newRecord); addRequest.execute(); return dsResponse; } }
Code:
<DataSource ID="contents" serverType="sql" tableName="content"> <fields> <field primaryKey="true" type="sequence" name="cntn_pk" hidden="true" export="false"></field> <field title="integer" type="integer" name="cntn_fk_customer"></field> <field type="datetime" name="cntn_createdOn" canEdit="false" canFilter="true" title="" showInGrid="true" export="true"></field> <field type="text" length="45" name="cntn_id" required="true" exportable="true" export="true"></field> <field title="bar" type="text" length="45" name="cntn_barCode" showInGrid="true" canEdit="false" export="true"></field> <field type="integer" name="cntn_fk_location" hidden="false"></field> <field title="quantity" type="float" name="cntn_quantity" export="true"></field> <field title="unit" type="text" length="45" name="cntn_unit" export="true" ></field> </fields> </DataSource>
Code:
<DataSource serverType="sql" dbName="Mysql" tableName="Customer" ID="Customer" > <fields> <field primaryKey="true" type="sequence" name="cstm_pk" hidden="true"></field> <field type="text" length="45" name="cstm_name" title="" required="true" export="true"></field> </fields> <operationBindings> <operationBinding operationType="update"> <serverObject className="test.server.DMIService" lookupStyle="new" /> <serverMethod>updateCustomer</serverMethod> </operationBinding> </operationBindings> </DataSource>
Comment