Hi,
we use the following code to save data ( autosave is false ).
databaseManager.startTransaction()
<pre-save code>
if (!databaseManager.saveData()) {
_thePressedButton = plugins.dialogs.showErrorDialog('Error in first Save', 'See log', 'OK');
_failedArray = databaseManager.getFailedRecords()
for (var j = 0; j < _failedArray.length; j++) {
_record = _failedArray[j];
plugins.Log.error('Error <xxxxxxx>: ' + _record.exception);
}
<handle error>
databaseManager.rollbackEditedRecords()
databaseManager.rollbackTransaction()
return -1
}
<post-save code>
if (!databaseManager.saveData()) {
_thePressedButton = plugins.dialogs.showErrorDialog('Error in second Save', 'See log', 'OK');
_failedArray = databaseManager.getFailedRecords()
for (var j = 0; j < _failedArray.length; j++) {
_record = _failedArray[j];
plugins.Log.error('Error <xxxxxxx>: ' + _record.exception);
}
<handle error>
databaseManager.rollbackEditedRecords()
databaseManager.rollbackTransaction()
return -1
}
if (!databaseManager.commitTransaction()) {
_thePressedButton = plugins.dialogs.showErrorDialog('Error in commit', 'See log', 'OK');
_failedArray = databaseManager.getFailedRecords()
for (var j = 0; j < _failedArray.length; j++) {
_record = _failedArray[j];
plugins.Log.error('Error <xxxxxxx>: ' + _record.exception);
}
<handle error>
databaseManager.rollbackEditedRecords()
databaseManager.rollbackTransaction()
return -1
}
else {
return 0
}
sometimes a user gets an error message " ‘Error in commit’ " but when we look in the log file there
are no entries of failed records.
If we check the database, everything that the user edited is saved perfectly.
The only way I can reproduce this is by commenting the startTransaction.
In that case there is a commitTransaction without a startTransaction.
I the get the same error and no lines in the log.
How can this happen (the code above always starts the transaction and the startTransaction command has no return code.
Regards,
Hans,
Could it be that in some situations, there is already a transaction?
In that case databaseManager.startTransaction() does nothing.
You can use hasTransaction() before startTransaction() to check.
Rob
Hi Rob,
I’ll put in a hasTransaction line to test that.
But if there already is a transaction, and startTansaction does nothing,
then commitTransaction should commit the existing transaction or not ?
B.t.w. there are now two users who get this message sometimes ( most of the time it’s oke).
Can a user only have 1 transaction open ( in our case there is never more then 1 )
Can you explain how does this mechanism work ?
We use the same code that we used with 4.1.x and there we never had this issue !!
Regards,
Hans
Servoy does not support nested transactions, so I guess following sequence may happen in your case:
start tx1
work 1
start tx2 // does nothing
work 2
commit tx2 // commits work 1 and 2
commit tx1 // fails, no transaction
Rob
Rob,
As I said it never happened in 4.x.
We do not use nested transactions ( as far as i know )
But i’ll put in a debug line with the hasTransaction and then i’ll get back to you.
Thanks,
Hi, we added 4 lines of debug ( logwrite ) code to our save method.
plugins.Log.debug('trans1 = ' + databaseManager.hasTransaction());
databaseManager.startTransaction()
plugins.Log.debug('trans2 = ' + databaseManager.hasTransaction());
<pre-save code>
if (!databaseManager.saveData()) {
_thePressedButton = plugins.dialogs.showErrorDialog('Error in first Save', 'See log', 'OK');
_failedArray = databaseManager.getFailedRecords()
for (var j = 0; j < _failedArray.length; j++) {
_record = _failedArray[j];
plugins.Log.error('Error <xxxxxxx>: ' + _record.exception);
}
<handle error>
databaseManager.rollbackEditedRecords()
databaseManager.rollbackTransaction()
return -1
}
<post-save code>
if (!databaseManager.saveData()) {
_thePressedButton = plugins.dialogs.showErrorDialog('Error in second Save', 'See log', 'OK');
_failedArray = databaseManager.getFailedRecords()
for (var j = 0; j < _failedArray.length; j++) {
_record = _failedArray[j];
plugins.Log.error('Error <xxxxxxx>: ' + _record.exception);
}
<handle error>
databaseManager.rollbackEditedRecords()
databaseManager.rollbackTransaction()
return -1
}
plugins.Log.debug('trans3 = ' + databaseManager.hasTransaction());
if (!databaseManager.commitTransaction()) {
_thePressedButton = plugins.dialogs.showErrorDialog('Error in commit', 'See log', 'OK');
_failedArray = databaseManager.getFailedRecords()
for (var j = 0; j < _failedArray.length; j++) {
_record = _failedArray[j];
plugins.Log.error('Error <xxxxxxx>: ' + _record.exception);
}
<handle error>
databaseManager.rollbackEditedRecords()
databaseManager.rollbackTransaction()
return -1
}
else {
application.output('Succesfull commmitTransaction');
}
plugins.Log.debug('trans4 = ' + databaseManager.hasTransaction());
as expected in the logfile most of the time we see the following sequence of logwrites :
IBISMain DEBUG 2010-06-16 14:45:14.401: trans1 = false
IBISMain DEBUG 2010-06-16 14:45:14.401: trans2 = true
IBISMain DEBUG 2010-06-16 14:45:14.417: trans3 = true
IBISMain DEBUG 2010-06-16 14:45:14.417: trans4 = false
But when the user gets the error ‘Error in commit’, ‘See log’:
The seuqence is as follows ( so number 4 is missing )
IBISMain DEBUG 2010-06-16 15:08:12.251: trans1 = false
IBISMain DEBUG 2010-06-16 15:08:12.251: trans2 = true
IBISMain DEBUG 2010-06-16 15:08:12.423: trans3 = true
AND there are no failed records in the log.
??? What could be the issue ?? ( again we never hat this issue with 3.x or 4.x )
Regards,
Can one of the Servoyans have a look at this.
We keep getting this error a few times a day.
How can I find out what is happening ?
Regards,
Hans,
databasemanager.commitTransaction does a saveData() before committing in the database.
If the saveData fails (for example because a field in the UI has invalid data), the commit will not continue.
You can add a saveData() before the commit and check its results, so we can see if that is what caused it.
The extra saveData is harmless in case it is successful, the commit won’t have edited records to save so it will continue with the commit.
Rob
Hi Rob,
as you can see in the code there is a savedata before the commit.
And the savedata is always succesfull !!
Or do You mean something else ??
Regards,
Weird,
Do you have after/before insert/update triggers that may create new edited records during the previous saveData(), which in the commit() cannot be saved?
Rob
We do have them, but as You can see in the code, after these pre/post methods a save is performed.
B.t.w. next week Sanneke will be at our site and i’ll look into this issue with her.
Regards,
Hi,
we still did’nt find the cause of this issue.
We tought it was related to another issue. That issue was resolved but the “commit” error stayed.
The application is used by 8 inhouse users and the error occurs several times a week
with different users.
Again : the commit returns a FALSE, but there are no failed records.
We are sure that it never happened with this solution in 4.x, it started with 5.1.
We are also pretty sure it happens when textarea’s are edited, but it is not reproducable.
Does this last info give anyone a clou what to look for ??
Regards,
dont you have anything in the log?
If hasTransaction() is still true, and saveData() also was true just before you say commit()
then there are no records that did go wrong, but really the actual commit didnt work.
But those should be reported in the error log/java console.
Hi Johan,
We put in an extra savedata just before the commitTransaction.
When te error occurs, the saveData is succesfull, but the committransaction returns false !!
There are no failed records.
There are no errors in the log file.
All data seems to be saved correctly.
The error occurs several times a day per user.
The users think it happens when they have been editing a textarea ( varchar2(3700))
but there not sure.
about 1 in 20 fail ( my estimation) .
Please advise how to proceed to get to the root cause of this issue !!
ADD. Info :
- this morning the error occurred when editing a regular textfield. So the hint about textareas is incorrect.
- I do not expect it has any influence, but just before the commitTransaction there is a releasAllLocks statement.
Regards,
are these web or smart clients?
because you talk about a log file. which file are you looking at? Or are you just testing and getting this in the developer?
Hi Johan,
I am talking about the smart client.
The errors occur in the smart client started from our production Servoy-Server.
With logfile I mean the servoy log file (servoy_log.txt)
And I use the log plugin from Patrick to write some “debug” info.
Regards,
but if you use the smart client then the error will not be on the server
so you should look at the Java Console when that state happens, do you really not see an error there?
I will start a java console with one of the customers.
Will get back here with more info.
Thanks,
It happened again and now there was an entry in the log :
<record>
<date>2010-09-20T10:06:03</date>
<millis>1284969963681</millis>
<sequence>45</sequence>
<logger>com.sun.deploy</logger>
<level>FINE</level>
<class>com.sun.deploy.util.LoggerTraceListener</class>
<method>print</method>
<thread>10</thread>
<message>ERROR - Debug - Throwable
com.servoy.j2db.persistence.RepositoryException: java.sql.SQLException: No active transaction found for id=0 No active transaction found for id=0
at com.servoy.j2db.dataprocessing.SQLEngine.endTransactions(SQLEngine.java:608)
at sun.reflect.GeneratedMethodAccessor299.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
at sun.rmi.transport.Transport$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Unknown Source)
at sun.rmi.transport.StreamRemoteCall.executeCall(Unknown Source)
at sun.rmi.server.UnicastRef.invoke(Unknown Source)
at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(Unknown Source)
at java.rmi.server.RemoteObjectInvocationHandler.invoke(Unknown Source)
at $Proxy1.endTransactions(Unknown Source)
at com.servoy.j2db.dataprocessing.Zcc.Za(Zcc.java:26)
at com.servoy.j2db.dataprocessing.Zsb.commitTransaction(Zsb.java:254)
at com.servoy.j2db.dataprocessing.JSDatabaseManager.js_commitTransaction(JSDatabaseManager.java:569)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:179)
at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:353)
at org.mozilla.javascript.optimizer.OptRuntime.callProp0(OptRuntime.java:111)
at org.mozilla.javascript.gen.c116._c0(svy_nav_dc_save:1234)
at org.mozilla.javascript.gen.c116.call(svy_nav_dc_save)
at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:387)
at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3127)
at org.mozilla.javascript.gen.c116.call(svy_nav_dc_save)
at com.servoy.j2db.scripting.Ztb.executeFunction(Ztb.java:196)
at com.servoy.j2db.Zwb.Za(Zwb.java:741)
at com.servoy.j2db.Zwb.Za(Zwb.java:1223)
at com.servoy.j2db.Zcc.Za(Zcc.java:1)
at com.servoy.j2db.ui.BaseEventExecutor.fireEventCommand(BaseEventExecutor.java:27)
at com.servoy.j2db.ui.BaseEventExecutor.fireEventCommand(BaseEventExecutor.java:18)
at com.servoy.j2db.ui.BaseEventExecutor.fireActionCommand(BaseEventExecutor.java:16)
at com.servoy.j2db.dataui.Zh.mouseReleased(Zh.java:2)
at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
</message>
</record>
Regards,
is there any other error report on the server or client that is that error or one error just before it?
Because there must be something just before going wrong somehow
Because what happens is at the moment you call commitTransaction() in the client, the server doesnt have a transaction connection anymore for that client, it is already gone (or it was never created)