Journaling

Ruslan Zasukhin ruslan_zasukhin at valentina-db.com
Wed Apr 18 12:50:22 CDT 2012


On 4/17/12 5:31 PM, "Fabian Kneubuehl" <support at ysd.ch> wrote:

Hi Fabian,

> I run a small benchmark around journaling and .Flush after each
> INSERT/UPDATE/DELETE.
>  
> I start with a new, empty database and insert a few thousands records. Here
> the times
>  
> Journaling+Flush: 40 Min.
> Journaling only: 3 Min.
> Flush only: 4 Min.
> None: 3 Min.
>  
> This will show you that journaling doesn¹t cost much time.

Interesting bench ...

> But as soon as you
> make a change an flush this  to the DB there will be a huge overhead (writing
> to journal, flush to disk, removing flushed data from journalŠ).

Not exactly, because e.g. No need remove data from journal.
Next operation will start write from the beginning.

  
> What I still not understand is what journaling exactly does: contains the
> .journal file all INSERT/UPDATE/DELETE data since the last flush and after a
> crash this data will be inserted into the DB so the user doesn¹t be aware of
> data loss? If this statement is right and I do not flush myself how often does
> Valentina call the flush method itself (only if cache is full or all xxx
> msecŠ)?

In short.

* atomic info stored in jourmal is 4KB cache page.
 into db we also save/read only 4KB pages.

So before we start change db file,
We drop OLD pages before changes to journal.

New pages with changes then go to db ...
In case of troubles, on next db.open engine see that exists .journal,
And it MUS BE in not finished state

Then engine return back all OLD pages into their original places ...
Something like this...


===========
NEW changes will be lost, because they was NOT COMMITED ...
Because crash did happens ...


===========
YOU must call db.Flush() at points where you see LOGIC "TRANSACTION" is
finished.

For example you adding invoice.
    * you touch table Invoice
    * you touch table IncoiveItems

Then you do db.Flush() == db.Commit()
  

In future db.Flush() will become empty command,
And instead will be used db.Commit()


-- 
Best regards,

Ruslan Zasukhin
VP Engineering and New Technology
Paradigma Software, Inc

Valentina - Joining Worlds of Information
http://www.paradigmasoft.com

[I feel the need: the need for speed]




More information about the Valentina-beta mailing list