* Don't run any daemons, those emit trace messages and other log
* entries and mess up our accounting.
*/
turnOffDaemons(envConfig);
envConfig.setAllowCreate(true);
env = new EnvironmentImpl(envHome, envConfig);
fileManager = env.getFileManager();
logManager = env.getLogManager();
/* Keep track of items logged and their LSNs. */
ArrayList testRecs = new ArrayList();
ArrayList testLsns = new ArrayList();
/*
* Intersperse:
* - log successfully
* - log w/failure because the item doesn't fit in the log buffer
* - have I/O failures writing out the log
* Verify that all expected items can be read. Some will come
* from the log buffer pool.
* Then close and re-open the environment, to verify that
* all log items are faulted from disk
*/
/* Successful log. */
addOkayItem(logManager, okCounter++,
testRecs, testLsns, logBufferSize);
/* Item that's too big for the log buffers. */
attemptTooBigItem(logManager, logBufferSize, testRecs, testLsns);
/* Successful log. */
addOkayItem(logManager, okCounter++,
testRecs, testLsns, logBufferSize);
/*
* This verify read the items from the log buffers. Note before SR
* #12638 existed (LSN state not restored properly after exception
* because of too-small log buffer), this verify hung.
*/
verifyOkayItems(logManager, testRecs, testLsns, true);
/* More successful logs, along with a few too-big items. */
for (;okCounter < 23; okCounter++) {
addOkayItem(logManager, okCounter, testRecs,
testLsns, logBufferSize);
if ((okCounter % 4) == 0) {
attemptTooBigItem(logManager, logBufferSize,
testRecs, testLsns);
}
/*
* If we verify in the loop, sometimes we'll read from disk and
* sometimes from the log buffer pool.
*/
verifyOkayItems(logManager, testRecs, testLsns, true);
}
/*
* Test the case where we flip files and write the old write buffer
* out before we try getting a log buffer for the new item. We need
* to
*
* - hit a log-too-small exceptin
* - right after, we need to log an item that is small enough
* to fit in the log buffer but big enough to require that
* we flip to a new file.
*/
long nextLsn = fileManager.getNextLsn();
long fileOffset = DbLsn.getFileOffset(nextLsn);
assertTrue((logFileMax - fileOffset ) < logBufferSize);
attemptTooBigItem(logManager, logBufferSize, testRecs, testLsns);
addOkayItem(logManager, okCounter++,
testRecs, testLsns, logBufferSize,
((int)(logFileMax - fileOffset)));
verifyOkayItems(logManager, testRecs, testLsns, true);
/* Invoke some i/o exceptions. */
for (;okCounter < 50; okCounter++) {
attemptIOException(logManager, fileManager, testRecs,
testLsns, false);
addOkayItem(logManager, okCounter,
testRecs, testLsns, logBufferSize);
verifyOkayItems(logManager, testRecs, testLsns, false);
}
/*
* Finally, close this environment and re-open, and read all
* expected items from disk.
*/
env.close();
envConfig.setAllowCreate(false);
env = new EnvironmentImpl(envHome, envConfig);
fileManager = env.getFileManager();
logManager = env.getLogManager();
verifyOkayItems(logManager, testRecs, testLsns, false);
/* Check that we read these items off disk. */