Hello everyone,

Can I change data during the synchronization of an Ultralite database?

We did some tests and there were situations in which the application crashed if we updated data during the download commit. In other scenarios, the sync fails if the data is updated/inserted after upload commit and before the download start.

We are wondering if we should avoid data manipulation during the whole sync.

If you have any documentation I'd like to read it as well =]

UltraliteJ for Android 16.0.2193

--- UPDATE ---

I build an example to test the "DisableConcurrency" parameter, but I didn't notice any difference. The data continues being inserted in the database.

Connection connection = DatabaseManager.connect(cfg);

SyncParms syncParms = ...
syncParms.setAdditionalParms("DisableConcurrency=1;");

connection.setSyncObserver(new SyncObserver() {

    @Override
    public boolean syncProgress(final int p, SyncResult data) {

        new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    DatabaseHelper.newCommand("INSERT INTO Test VALUES('S_' || GETDATE() || '_' || NEWID(), " + p + ")").executeStatement();
                } catch(Exception ex) {
                    Log.d("SYNC", ex.getMessage(), ex);
                }
            }
        }).start();

        return false;
    }
});

connection.synchronize(syncParms);

asked 10 Mar, 13:23

Alex's gravatar image

Alex
975153747
accept rate: 25%

edited 13 Mar, 14:56


Can I change data during the synchronization of an Ultralite database?

Yes, with caveats (of course).

According to the documentation on UltraLite Concurrency read/write access is permitted with the possibility that a download could fail under some conditions. Ultralite generally allows you to use an option to disable this level of concurrency. That is available through the UltraliteJ API.


None of that explains the crashing though. It may be related to something that has been fixed more recently than your build but it may be due to an undiagnosed problem. The timing of the crash with the download commit could be causing some sort of race condition and if it becomes a major concern for you, you should probably contact support so that can be looked into.

permanent link

answered 10 Mar, 13:49

Nick%20Elson%20SAP%20SQL%20Anywhere's gravatar image

Nick Elson S...
6.9k29101
accept rate: 31%

edited 10 Mar, 17:48

Contrary to the docs, you must be able to set the "additional" sync parameters on Android. If not, then that's a bug.

(10 Mar, 15:45) Tim McClements
Replies hidden

As Nick has pointed out, the caveat is around conflicting updates. If you modify something the download later needs to modify, the download will roll back. If you attempt to modify something the download has modified already, your request will fail with a locked/modified kind of error.

Certainly if you encounter a crash, please post the best repro info you can! (Not sure what you mean about not handling the sync, but again, things should work fine.)

(10 Mar, 15:52) Tim McClements
Replies hidden

Tim is correct about that being available with the UltraLiteJ API; using the setAdditionalParms( ) method of the SyncParms class. I've correct my original answer and have notified the doc team on the error.

(10 Mar, 17:45) Nick Elson S...

@Nick Elson S... What happens when the DisableConcurrency is set and I try to update/insert a register during upload? It would fail the statement? The sync would fail? The statement would wait until the sync if finished (holding the execution thread?)

(13 Mar, 07:48) Alex

@Tim McClements sorry, I was not clear about "handle the sync", but basically I have a guess about that sequence id error that I posted some time ago. I think it may be related to this issue. As we have a load balance, I was wondering if you change data during some critical phases of the sync would mess up the sync sequence information somehow. I'm gathering more information from the logs and as soon as I have it I will open a ticket, as you suggested.

(13 Mar, 07:52) Alex
1

Any insert, update or delete should block until the synchronization completes; when you have DisableConcurrency set to 1.

(13 Mar, 10:45) Nick Elson S...
Replies hidden

Thank you! Probably we will toggle this feature on.

(13 Mar, 12:06) Alex

@Nick Elson could you please check my update? I couldn't manage to get this working.

(13 Mar, 14:58) Alex
showing 4 of 8 show all flat view
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×278
×70
×60
×29
×27

question asked: 10 Mar, 13:23

question was seen: 99 times

last updated: 13 Mar, 14:58