Issue with transaction

Questions, tips and tricks and techniques for scripting in Servoy

Re: Issue with transaction

Postby Hans Nieuwenhuis » Mon Sep 13, 2010 2:04 pm

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,
Hans Nieuwenhuis
Betagraphics
http://www.deltics.nl
http://www.betagraphics.nl

Servoy Version 7.3.1
Java version 1.7.0.x
Database Oracle 11g
User avatar
Hans Nieuwenhuis
 
Posts: 1026
Joined: Thu Apr 12, 2007 12:36 pm
Location: Hengelo, The Netherlands

Re: Issue with transaction

Postby jcompagner » Mon Sep 13, 2010 2:31 pm

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?
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8833
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: Issue with transaction

Postby Hans Nieuwenhuis » Mon Sep 13, 2010 2:39 pm

I will start a java console with one of the customers.
Will get back here with more info.

Thanks,
Hans Nieuwenhuis
Betagraphics
http://www.deltics.nl
http://www.betagraphics.nl

Servoy Version 7.3.1
Java version 1.7.0.x
Database Oracle 11g
User avatar
Hans Nieuwenhuis
 
Posts: 1026
Joined: Thu Apr 12, 2007 12:36 pm
Location: Hengelo, The Netherlands

Re: Issue with transaction

Postby Hans Nieuwenhuis » Mon Sep 20, 2010 5:20 pm

It happened again and now there was an entry in the log :

Code: Select all
<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,
Hans Nieuwenhuis
Betagraphics
http://www.deltics.nl
http://www.betagraphics.nl

Servoy Version 7.3.1
Java version 1.7.0.x
Database Oracle 11g
User avatar
Hans Nieuwenhuis
 
Posts: 1026
Joined: Thu Apr 12, 2007 12:36 pm
Location: Hengelo, The Netherlands

Re: Issue with transaction

Postby jcompagner » Mon Sep 20, 2010 5:28 pm

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)
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8833
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: Issue with transaction

Postby Hans Nieuwenhuis » Mon Sep 20, 2010 5:46 pm

No other error in java log on client, or in servoy_log on server !!

the transactions exits just before the committransactions, cause I test with hasTransaction and put the output in application logfile.

Regards,
Hans Nieuwenhuis
Betagraphics
http://www.deltics.nl
http://www.betagraphics.nl

Servoy Version 7.3.1
Java version 1.7.0.x
Database Oracle 11g
User avatar
Hans Nieuwenhuis
 
Posts: 1026
Joined: Thu Apr 12, 2007 12:36 pm
Location: Hengelo, The Netherlands

Re: Issue with transaction

Postby jcompagner » Mon Sep 20, 2010 5:53 pm

databaseManager.hasTransaction() doesnt test this,
that is just a test on the client, that the client thinks it has a transaction object.

Problem is here that something went wrong on the server and the server dropped the transaction connection for that client already.
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8833
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: Issue with transaction

Postby jcompagner » Mon Sep 20, 2010 6:01 pm

just a guess, but is there someone changing/updating server definitions through the admin pages at the same time?
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8833
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: Issue with transaction

Postby Hans Nieuwenhuis » Mon Sep 20, 2010 6:08 pm

No, I am sure that that does not happen.

I am the only one that has access to the admin page.

In the save routine I do a check if a transactions exists, then I do an extra save ( as You asked me ) and then the committransaction is the
next statement. So this is done in a few lines in 1 method and no other method is called in between.

The commitTransaction returns false in this case (this only happens now and then, in 99% of the call's to this save method commitTransaction returns true)

Regards,
Hans Nieuwenhuis
Betagraphics
http://www.deltics.nl
http://www.betagraphics.nl

Servoy Version 7.3.1
Java version 1.7.0.x
Database Oracle 11g
User avatar
Hans Nieuwenhuis
 
Posts: 1026
Joined: Thu Apr 12, 2007 12:36 pm
Location: Hengelo, The Netherlands

Re: Issue with transaction

Postby Hans Nieuwenhuis » Tue Sep 21, 2010 10:36 am

Johan,

Is there anything I can do to get to the rootcause if this issue ??

Regards,
Hans Nieuwenhuis
Betagraphics
http://www.deltics.nl
http://www.betagraphics.nl

Servoy Version 7.3.1
Java version 1.7.0.x
Database Oracle 11g
User avatar
Hans Nieuwenhuis
 
Posts: 1026
Joined: Thu Apr 12, 2007 12:36 pm
Location: Hengelo, The Netherlands

Re: Issue with transaction

Postby jcompagner » Tue Sep 21, 2010 10:42 am

no not yet, the only thing we can currently think of is that the server is restarted or the somehow the server configuration is touched through the admin pages.

that exception says, id=0 and that 0 means that this is the very first transaction that is ever done for that server config.
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8833
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: Issue with transaction

Postby Hans Nieuwenhuis » Tue Sep 21, 2010 10:55 am

I am sure that that is not the case !

This is about the 30'st transaction of that day. ( and 29 went oke)

Since startTransaction does not return anything I am not sure if the transaction has been created when this problem occurs.

The save is done in the framework and the transaction exists only for a very short time ( start transaction, pre-save, save, post-save, save, commit transaction)
so I can't check it on the server admin page.

Regards,
Hans Nieuwenhuis
Betagraphics
http://www.deltics.nl
http://www.betagraphics.nl

Servoy Version 7.3.1
Java version 1.7.0.x
Database Oracle 11g
User avatar
Hans Nieuwenhuis
 
Posts: 1026
Joined: Thu Apr 12, 2007 12:36 pm
Location: Hengelo, The Netherlands

Re: Issue with transaction

Postby martinh » Thu Oct 21, 2010 6:09 pm

I see an issue that could be related to the situation that Hans describes.

When doing:

Code: Select all
databaseManager.startTransaction()


I don't see a transaction on the admin pages after this statement.

But when I step by the next statement (which I added, because I didn't see a transaction appear)

Code: Select all
databaseManager.refreshRecordFromDatabase(forms[_form].foundset, forms[_form].foundset.getSelectedIndex())


then I see a transaction on the adminpages.

Similar issue when locking records:

Code: Select all
databaseManager.acquireLock(forms[_form].foundset, 0)
databaseManager.startTransaction()


then I don't have a transaction, but I do have a lock. Where changing the order of those statements:

Code: Select all
databaseManager.startTransaction()
databaseManager.acquireLock(forms[_form].foundset, 0)


then I do have a transaction and I have a lock.

Can someone explain that?
Martin
------------------------------------------------
Servoy Developer
Version 5.2.10/5.2.13
Java version 1.6 update 31
Database SQL Server 2008 R2
martinh
 
Posts: 857
Joined: Wed May 09, 2007 5:34 pm
Location: Belgium

Re: Issue with transaction

Postby martinh » Thu Oct 21, 2010 6:15 pm

Hans Nieuwenhuis wrote:
Code: Select all
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
}



Hans,

If the issue that I've seen has something to do with your case and I'm also familiar with that pre-save/post-save setup, then probably you must do this:

    User presses edit button
    Start Transaction
    Refresh record from database
    User changes fields
    User presses save button
    Run pre-save code
    Save data
    Run post-save code
    Save data
    Commit Transaction

Martin
Martin
------------------------------------------------
Servoy Developer
Version 5.2.10/5.2.13
Java version 1.6 update 31
Database SQL Server 2008 R2
martinh
 
Posts: 857
Joined: Wed May 09, 2007 5:34 pm
Location: Belgium

Re: Issue with transaction

Postby Hans Nieuwenhuis » Thu Oct 21, 2010 6:31 pm

Hi Martin,

As Johan described to me, starting a transaction only sets a flag.

The first change ( saveData ) to the database will start the actual transaction.

So it is expected behaviour that you don not see the transaction after the startTransaction command.

Maybe Johan can confirm my explanation or correct it ?

B.t.w. :

User presses edit button
Start Transaction
Refresh record from database
User changes fields
User presses save button
Run pre-save code
Save data
Run post-save code
Save data
Commit Transaction




In my opinion doing it this way leaves the transaction is open much to long.

I suggest :

enter edit mode
user changes data
user hits save button
validation checks
presave method
saveData
postsave method
saveData
commitTransaction


Regards,
Hans Nieuwenhuis
Betagraphics
http://www.deltics.nl
http://www.betagraphics.nl

Servoy Version 7.3.1
Java version 1.7.0.x
Database Oracle 11g
User avatar
Hans Nieuwenhuis
 
Posts: 1026
Joined: Thu Apr 12, 2007 12:36 pm
Location: Hengelo, The Netherlands

PreviousNext

Return to Methods

Who is online

Users browsing this forum: No registered users and 11 guests

cron