1. François Van Lerberghe
  2. Valentina Database ADK
  3. Tuesday, April 28 2020, 08:05 AM
  4.  Subscribe via email
I want to understand better how the ".journal" file works in these situations
1. When I do VDatabase.Flush, is it "emptied" ?
2. I have to update a table. If my app is crashing after the update, what's happening when I relaunch my app

  • if I do VTable1.Update but not any Flush before the crash
  • if I do VDatabase.Flush and next, VTable1.Update before the crash
  • if I do VTable1.Update and next, VTable1.Flush before the crash
  • if I do VTable1.Update and next, VDatabase.Flush before the crash

What's the state of my Table1 in these 4 situations after the database is reopened ?
Comment
There are no comments made yet.
Ivan Smahin Accepted Answer

1. When I do VDatabase.Flush, is it "emptied" ?


Not always - better say "journal is invalidated". I mean even if it's not empty it would not be used after reopen database to restore.


if I do VTable1.Update but not any Flush before the crash


In most of cases you will loss this changes. But if there are few operations after update db.Flush can be called internally, so you will get the "last known consistent state" after restoring the db.


if I do VDatabase.Flush and next, VTable1.Update before the crash


VDatabase.Flush is just something like "store-point/save-point". It is guaranteed that all the changes before "flush" is durable and would not be lost.


if I do VTable1.Update and next, VTable1.Flush before the crash


Actually VTable1.Flush do nothing regarding to journal - it is only about emptying the internal cache writing out dirty table's data to the disk.
In other words it is the same case as "if I do VTable1.Update but not any Flush before the crash".


if I do VTable1.Update and next, VDatabase.Flush before the crash


Your "update" will be fixed on disk and will not be reverted after the db restore.
Comment
There are no comments made yet.
  1. more than a month ago
  2. Valentina Database ADK
  3. # 1

Actually VTable1.Flush do nothing regarding to journal - it is only about emptying the internal cache writing out dirty table's data to the disk.
In other words it is the same case as "if I do VTable1.Update but not any Flush before the crash".
Thus, in this particular case,
Reopening the database after a crash, VTable1 will not be updated.
But if I delete the .journal file and next, reopen the database, VTable1 will be updated.
Do I understand correctly ?
What's the purpose of the .journal file then ?
Comment
There are no comments made yet.
  1. more than a month ago
  2. Valentina Database ADK
  3. # 2
Ivan Smahin Accepted Answer
If you manually delete the journal file after the crash you do it on your own risk. You might be lucky and that "update" will be there and even db.diagnose says it's ok, but it is not for most of cases.

Initially, any "Flush" method was for forcing "write dirty cache's pages" to the disk. So db.Flush did it for whole database, Table.Flush did it for particular table, etc...
It was mostly for having a guarantee that "dirty" pages have been really written to the disk.

Without "Flushes" it could be following - in case of app crash (somewhere in the middle - even not Valentina related places) - some/all "updates" are still in-memory (cache) and you see no (or even worst - part of) updates after restarting.
The worst case was db corruptions after such crashes.
Assume you did some t1.f1 update and do no flushes, then, call something that crashes the app.
The cache may write done some part of data to the disk internally for own needs, so db's files are not in consistence state at the moment of the crash. And you get corrupted db as a result.

To prevent such corruptions we use the journal. Db.Flush makes the safe-point in the journal, and in case of such crashes we are able to revert all file changes back to that safe-point moment. But it is true for Db.Flush only - not for Table.Flush.
Comment
There are no comments made yet.
  1. more than a month ago
  2. Valentina Database ADK
  3. # 3
Ok.
Thank you for these extended explanations.
Comment
There are no comments made yet.
  1. more than a month ago
  2. Valentina Database ADK
  3. # 4
  • Page :
  • 1


There are no replies made for this post yet.
However, you are not allowed to reply to this post.

Categories

Announcements & News
  1. 0 subcategories
Valentina Studio
  1. 2 subcategories
Valentina Server
  1. 4 subcategories
Valentina Database ADK
  1. 0 subcategories
Valentina Reports ADK
  1. 0 subcategories
Other Discussions
  1. 2 subcategories
BETA Testing
  1. 0 subcategories
Education & Research
  1. 0 subcategories