File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -266,10 +266,7 @@ namespace mongo {
266
266
assert ( len % BLKSZ == 0 );
267
267
268
268
AlignedBuilder b (BLKSZ);
269
- // we don't rezero a journal file upon recycling (see removeOldJournalFile). given that, its contents
270
- // don't matter, the important thing is it is prealloced. so we fill it with a rand # here : if it not
271
- // being zeroed were a problem, we'd want to catch that sooner than later (upon a recycling)
272
- memset ((void *)b.buf (), rand (), BLKSZ);
269
+ memset ((void *)b.buf (), 0 , BLKSZ);
273
270
274
271
ProgressMeter m (len, 3 /* secs*/ , 10 /* hits between time check (once every 6.4MB)*/ );
275
272
@@ -327,7 +324,17 @@ namespace mongo {
327
324
filesystem::path filepath = getJournalDir () / fn;
328
325
if ( !filesystem::exists (filepath) ) {
329
326
// we can recycle this file into this prealloc file location
330
- boost::filesystem::rename (p, filepath);
327
+ filesystem::path temppath = getJournalDir () / (fn+" .temp" );
328
+ boost::filesystem::rename (p, temppath);
329
+ {
330
+ // zero the header
331
+ File f;
332
+ f.open (temppath.string ().c_str (), false , true );
333
+ char buf[8192 ];
334
+ memset (buf, 0 , 8192 );
335
+ f.write (0 , buf, 8192 );
336
+ }
337
+ boost::filesystem::rename (temppath, filepath);
331
338
return ;
332
339
}
333
340
}
You can’t perform that action at this time.
0 commit comments