Transactions in P10 OfflineDataSync

Transactions in P10 OfflineDataSync

  

Hello,

I'm wondering if anybody can give me some insight on the expected behavior of transactions (or lack thereof) in OfflineDataSync on P10.  It appears as though even though the sync may have an error, that any server-side action will still go through.  For example:

Let's say I have 5 records I've added in local storage.  I loop through these records in OfflineDataSync, storing them to the server.  When I hit the 4th record, let's say I get a foreign key error, halting the sync.  In a transaction, normal the first 3 records would be rolled back, but in my limited experience the first 3 records I have found saved to the server.  Is this behavior expected?  Can anybody else confirm that this is correct and could be expected?


Hi Mike,

Every request to the server creates a new transaction, so if you want to make transactional bulk updates you should create a server action that receives all the records you want to store on the server (db).

So as long as I keep all my actions on a record within one server action, you're saying that is considered one server request right?  I will continue my testing, as this did not seem to be the case.

Let me rephrase:

1) go to Logic tab 

2) under the server actions folder create an action

3) create an input parameter that will receive a list of records to be stored on the database

4) on the client action that does the sync work call that server action (only once - with all the records you want)

Thank you Joao, I look forward to performing more tests.

Hello Mike,


Just to confirm, are you performing several consecutive calls to a server action in your synchronization logic (one per record)? This also has the disadvantage of a performance penalty because each call to the server takes a lot of time.


See this example in the documentation where all the data is fetched locally and then sent all at once to the server in a call to a server action:


https://success.outsystems.com/Documentation/10/Developing_an_Application/Use_Data/Offline/02_Data_Synchronization_Patterns/03_Read%2F%2FWrite_Data_Last_Write_Wins#OfflineDataSync_Logic



No Paulo, I'm not doing that.  If and when at all possible, I don't make multiple calls to the server, rather keep all server calls within one action.  This suspicion that I had happened within a server action.  I was within a server action, one of the records I was attempting to insert failed, yet the previous records within the same action were inserted and committed.