1. John Vanleeuwe
  2. PowerBuilder
  3. Monday, 13 May 2019 15:16 PM UTC

Hi guys,

 

Recently one of our customers is complaining about "lost data".  I am not yet sure how this happens, but i have a feeling it has to do with the autocommit property of the transaction object.

 

I am using PB2017 R3 with a SQLAnywhere 11 database.  Once or twice in a month this particular customer looses data. When i try to translate the logfile, all i can see is "checkpoints", but not one actual sql statement of update/insert/delete of any table.

 

We do have a function to upload blobs in our db and i am guessing an autocommit is wrongly set... It's just a hunch , a feeling ... Could the db connection autocommit be the cause of this behaviour ? 

 

Sadly because there's not one single sql statement in the translated logfile , i can't recover customers lost data...

 

 

TIA

John

 

 

Roland Smith Accepted Answer Pending Moderation
  1. Wednesday, 15 May 2019 00:22 AM UTC
  2. PowerBuilder
  3. # 1

I did a search and found SQL Anywhere doc that said that once a transaction is committed or rolled back, it is deleted from the transaction log.

Somehow the app is not committing the changes, they are getting rolled back instead.

Comment
There are no comments made yet.
Roland Smith Accepted Answer Pending Moderation
  1. Tuesday, 14 May 2019 18:11 PM UTC
  2. PowerBuilder
  3. # 2

Your app is probably AutoCommit=False and a COMMIT isn't being issued after the updates are made. Then on exit the app is issuing a ROLLBACK automatically.

The proper thing to do is keep AutoCommit=True until just before updating. Change it to False and then issue the updates with error checking/rollback. Then when the last update is done, do a COMMIT and switch back to AutoCommit=True. This way if the Save button does an update on multiple DataWindow/DataStore objects and one fails, the rollback will rollback all the changes within the 'unit of work'.

 

 

Comment
  1. mike S
  2. Tuesday, 14 May 2019 18:27 PM UTC
run the save process through the debugger and check to see if when the transaction is commited if ever. just step though your update logic while also having a sql window up where you select from your invoice table. at the point where you see the invoice, it has been committed.



If that all seems to be working properly, then either a user is deleting the invoice (you didn't say if they can or can not), or maybe the database is having data issues.





  1. Helpful
There are no comments made yet.
Brad Mettee Accepted Answer Pending Moderation
  1. Tuesday, 14 May 2019 14:41 PM UTC
  2. PowerBuilder
  3. # 3

When you translate the log, are you including rolled back transactions? What about trigger-generated transactions? (by default neither are included)

Comment
There are no comments made yet.
Ricardo Jasso Accepted Answer Pending Moderation
  1. Monday, 13 May 2019 18:48 PM UTC
  2. PowerBuilder
  3. # 4

John,

It must be that SQLCA.AutoCommit is set to False before making the connection to the database. If the user starts making operations to the database and an error ocurrs that chrashes the application everything will get rolled back. That'll explain why he could print the invoice but no invoice is found in the database.

If the user properly closes the application a Commit will be issued before the SQLCA object is destroyed and all data will be saved even if the code does not sets AutoCommit = True.

I experienced this when I started developing applications using PB. Now I always start a connection with AutoCommit = True and set it to False before making updates to the database. After issuing a Commit Using SQLCA I will set it to True again.

Regards,

Ricardo

Comment
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Monday, 13 May 2019 18:45 PM UTC
  2. PowerBuilder
  3. # 5

Hi John;

  Normally if the UpdateBlob command works once for this App's business transaction - then it should work 100% all the time. The only two things that I can think of that might interrupt this blob processing are:

1) The UpdateBlob command is failed by the DBMS and the PB App fails to check the SQLCA status to catch the error. Yet the DB Commit continues and commits all datum but the blob.

2) Since you are using ODBC, and the blob data is variable - it might be possible that the "PBMaxBlobSize" and/or "PBMaxTextSize" are not set to the proper largest size setting in either the SQLCA.DBParm or via the PBODBC170.INI file. Thus, the Blob processing is curtailed the odd time if the blob exceeds a max setting.

HTH

Regards ... Chris

Comment
There are no comments made yet.
John Vanleeuwe Accepted Answer Pending Moderation
  1. Monday, 13 May 2019 15:30 PM UTC
  2. PowerBuilder
  3. # 6

Roland,

 

thank you, but can the wrong use of this autocommit lead to "blank" sybase sql logfiles ? Its not one record he's missing, he's missing everything from a few hours of work. Yet he can show me a PDF of an invoice for example he created , nowhere to be found in our database , nor in our translated sql log file...:(

 

 

TIA

John

Comment
  1. Roland Smith
  2. Monday, 13 May 2019 15:31 PM UTC
Maybe he is pointed to the wrong database.
  1. Helpful
  1. mike S
  2. Monday, 13 May 2019 15:37 PM UTC
Can you print/saveas pdf invoices in your app without saving first?

do you provide the ability to delete invoices?

  1. Helpful
  1. John Vanleeuwe
  2. Monday, 13 May 2019 15:48 PM UTC
Roland : Only 1 odbc connection for this customer. He would complain seeing other customers data or invoices. Besides every database has it's own user id and password, if he would try to connect to the wrong database , then he would receive a password/userid error...



Mike S : No , first dw_save , then print or pdf. Besides , i would agree this is a possibility if i could see the SQL statements in the translated logfile , but i am not seeing anything , no insert , no delete , no update ,nada :(

  1. Helpful
There are no comments made yet.
Roland Smith Accepted Answer Pending Moderation
  1. Monday, 13 May 2019 15:26 PM UTC
  2. PowerBuilder
  3. # 7

The UPDATELOB statement acts as if AutoCommit = True, even if it is set to False. My personal preference is to have AutoCommit = True and then set it to False prior to performing an update. I then switch it back to True after the updates are done. If an error happens on the second update, both can be rolled back. This method supports the Unit Of Work design pattern.

My guess is the user forgot to click the save button.

Hanlon's Razor:

"Never attribute to malice that which is adequately explained by stupidity."

 

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.