Page 1 of 1

BusyTimeout and high concurency question

Posted: Sun 15 Jan 2017 13:56
by Max Terentiev
Hi,

I have two kinds of threads in my application:

1. Threads for fast writes: insert/update/delete one record.

2. Threads for bulk operations: insert/delete millions records.

Bulk opterations are split by 5000 inserts/deletes per transaction.

My question is: how long I should sleep between bulk transactions to let other threads perform fast (one record) insert/update/delete transactions ?

For bulk operations I perform:

Code: Select all

while not done do
   begin
   StartTransaction;
   Make5000Inserts;
   Commit;
   Sleep(PauseTime); // How long I should sleep to let other threads perform quick writes ?
   end;
PauseTime should depends on how frequently LiteDac checks for active transactions during BusyTimeout ? If I set 100 milliseconds - it's will be enouch for other threads (who waits in BusyTimeout) to see what database no longer locked and it's possible to perfrom their fast transactions ?

Thanks for help !

Re: BusyTimeout and high concurency question

Posted: Mon 16 Jan 2017 12:37
by MaximG
Setting any specific timeout value in this case is not entirely correct, because the execution time of operations in the used threads will depend on many factors, i.e. it will be determined by the environment parameters. In this case it is better to use one of the threads synchronization methods.