Re: [sqlite] syncing two sqlite databases and db corruption

2013-11-13 Thread Simon Slavin

On 14 Nov 2013, at 12:56am, Mayank Kumar (mayankum)  wrote:

> When rsyncing , we sync both the db file and the journal file(we sync the 
> complete folder).
> 
> 
> My question , if primary is in the middle of a transaction

Wait.  You're syncing by copying files, when one or other file may be open ?  
Worse still, while one of them might be in the middle of a transaction ?  No, 
that's just not going to work.  All sorts of issues, including corruption and 
forgetting the most recent transaction.

If you want to sync by copying files, make sure none of them are open while 
you're copying.
If you need to sync while the primary file may be being written, use the SQLite 
backup API:

http://www.sqlite.org/backup.html

Simon.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] syncing two sqlite databases and db corruption

2013-11-13 Thread Mayank Kumar (mayankum)
Hi

This is a follow up questions related to the db corruption question I asked a 
few days earlier. Our architecture is such that we have two roles primary and 
secondary and the secondary syncs(rsyncs) the sqlite db from the primary from 
time to time. Also the primary sometime sends records to secondary to 
write(incremental syncs) to its db using sqlite commands.


When rsyncing , we sync both the db file and the journal file(we sync the 
complete folder).


My question , if primary is in the middle of a transaction and the secondary 
syncs both the db and the journal file using rsync, can this corrupt the sqlite 
db on the secondary side or when the next write happens on the secondary side, 
the sqlite will detect the presence of the journal (although its copied from 
the primary) and revert the last transaction before doing any new writes ?

-Mayank
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users