Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,14 @@ public List<Long> getReadPositionList() {

public void assertOrdered(final boolean read, final boolean forward) {
final List<Long> list = read ? _readPositions : _writePositions;
final long previous = forward ? -1 : Long.MAX_VALUE;
long previous = forward ? -1 : Long.MAX_VALUE;
for (final Long position : list) {
if (forward) {
assertTrue("Position should be larger", position > previous);
} else {
assertTrue("Position should be smaller", position < previous);
}
previous = position;
}
}
}
29 changes: 24 additions & 5 deletions persistit/core/src/test/java/com/persistit/WarmupTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ public void testWarmup() throws Exception {

@Test
public void readOrderIsSequential() throws Exception {

Exchange ex = _persistit.getExchange("persistit", "WarmupTest", true);
BufferPool pool = ex.getBufferPool();

Expand Down Expand Up @@ -107,19 +106,39 @@ public void readOrderIsSequential() throws Exception {
_persistit.copyBackPages();
_persistit.close();

_persistit = new Persistit();
/*
* recordBufferInventory() at the close above interleaves its own tree stores
* with the buffer scan, so some recorded pages are the inventory tree's own
* pages; the closing checkpoint flushes those to the journal with no
* copyBack(), and on restart they would be served from the journal
* (VolumeStorageV2.readPage consults readPageFromJournal first), bypassing
* the injected volume channel. Reopen with inventory recording disabled,
* drain the journal into the volume, and close again so every recorded page
* lives in the volume file; the preload below then reads them through the
* tracked channel deterministically instead of racing the journal.
*/
_config.setBufferInventoryEnabled(false);
_config.setBufferPreloadEnabled(false);
_persistit.setConfiguration(_config);
_persistit.initialize();
_persistit = new Persistit(_config);
_persistit.copyBackPages();
_persistit.close();

_persistit = new Persistit(_config);

final Volume volume = _persistit.getVolume("persistit");
final MediatedFileChannel mfc = (MediatedFileChannel) volume.getStorage().getChannel();
final TrackingFileChannel tfc = new TrackingFileChannel();
mfc.injectChannelForTests(tfc);
pool = volume.getStructure().getPool();
pool.preloadBufferInventory();
assertTrue("Preload should have loaded pages from journal file", tfc.getReadPositionList().size() > 0);
/*
* With the recorded pages copied back to the volume above, preload reads
* them through the injected volume channel rather than the journal, so the
* channel sees a non-empty, strictly ascending sequence of reads (warmup
* issues them in page order via PageNode.READ_COMPARATOR).
*/
assertTrue("Preload should have read the recorded pages from the volume file",
tfc.getReadPositionList().size() > 0);
tfc.assertOrdered(true, true);
}
}
Loading