Db sync mech

Db syncronization mechanism
Platform are checking periodicly new data from db and syncronize it when new changes appears in DB. This process goes by next algorithm:
 * 1) In UpdateThread::m_transactionCount platform store number of all commited and rollbacked transactions that contain INSERT, UPDATE and DELETE SQL requests;
 * 2) All syncronisation goes into UpdateThread object in method run in the infinite loop and in the standalone thread;
 * 3) Check for the difference between DB and cache data goes in the begining of UpdateThread::run in UpdateThread::compareTransactionNumber method;
 * 4) UpdateThread::compareTransactionNumber perform SELECT SQL query to the pg_stat_database - domestic view of PostgreSQL containing information about SQL statictics for client databases ;
 * 5) SQL queries count from this view is comparing with UpdateThread::m_transactionCount;
 * 6) If UpdateThread::m_transactionCount is less then number in pg_stat_database then we need to do syncronization. We set UpdateThread::m_transactionCount equal to the value, selected from pg_stat_database and start sync;
 * 7) If UpdateThread::m_transactionCount is equal or more than value from pg_stat_database then we doesnt need syncronization (statistics are updated slow) so UpdateThread just go to sleep till next iteration;

Because syncronization is very long process(and cause lots of problems with request processing) we should count each write transaction performed by platform. How to do that:
 * 1) After you done your transaction, you should lock UpdateThread;
 * 2) Call UpdateThread::incrementTransactionCount(i) method (where i - number of performed transactions)
 * 3) Unlock UpdateThread;

Example:

newTmpUser = m_queryExecutor->insertNewTmpUser(newTmpUser); m_updateThread->lockWriting; m_updateThread->incrementTransactionCount; m_updateThread->unlockWriting;