FilesThe data file format is unchanged. Journal files are placed in /data/db/journal/. RunningRun with --journal to enable journaling/durable storage. Both mongod and test support this option. Declaring Write IntentWhen writing mongod kernel code, one must now declare an intention to write. Declaration of the intent occurs before the actual write. See db/dur.h. The actual write must occur before releasing the write lock. When you do your actual writing, use the pointer that dur::writing() returns, rather than the original pointer.
Foo *foo;
getDur().writing(thing)->bar = something;
int *x;
getDur().writingInt(x) += 3;
DiskLoc &loc;
loc.writing() = newLoc;
void *p;
unsigned len;
memcpy( getDur().writingPtr(p,len), src, len );
Try to declare intent on as small a region as possible. That way less information is journalled. For example BigStruct *b; dur::writing(b)->x = 3; // less efficient *dur::writing(&b->x) = 3; // more efficient However, there is some overhead for each intent declaration, so if many members of a struct will be written, it is likely better to just declare intent on the whole struct. Testsjstests/dur/ contains tests for durability. mongo --nodb jstests/dur/<testname>.js Administrative# dump journal entries during any recover, and then start normally mongod --journal --durOptions 1 # recover and terminate mongod --journal --durOptions 4 # dump journal entries (doing nothing else) and then terminate mongod --journal --durOptions 7 # extra checks that everything is correct (slow but good for qa) mongod --journal --durOptions 8 Diagrams |

PLEASE POST QUESTIONS IN THE USER GROUPS FORUM. Post non-question comments and helpful hints here.
blog comments powered by Disqus