Skip to content

Commit

Permalink
Fix bug in PageList.evict
Browse files Browse the repository at this point in the history
Pages that are loaded but not bound, do not have a swapper associated with them.
Looking for a swapper that is not there throws an exception, so we now avoid doing that.
  • Loading branch information
chrisvest committed May 26, 2017
1 parent 45c91ff commit 13bbefe
Showing 1 changed file with 25 additions and 21 deletions.
Expand Up @@ -381,34 +381,38 @@ public boolean tryEvict( long pageRef, EvictionEventOpportunity evictionOpportun

private void evict( long pageRef, EvictionEvent evictionEvent ) throws IOException
{
int swapperId = getSwapperId( pageRef );
SwapperSet.Allocation allocation = swappers.getAllocation( swapperId );
PageSwapper swapper = allocation.swapper;
long filePageId = getFilePageId( pageRef );
evictionEvent.setFilePageId( filePageId );
evictionEvent.setCachePageId( pageRef );
evictionEvent.setSwapper( swapper );
if ( isModified( pageRef ) )
int swapperId = getSwapperId( pageRef );
if ( swapperId != 0 )
{
FlushEvent flushEvent = evictionEvent.flushEventOpportunity().beginFlush( filePageId, pageRef, swapper );
try
{
long address = getAddress( pageRef );
long bytesWritten = swapper.write( filePageId, address );
explicitlyMarkPageUnmodifiedUnderExclusiveLock( pageRef );
flushEvent.addBytesWritten( bytesWritten );
flushEvent.addPagesFlushed( 1 );
flushEvent.done();
}
catch ( IOException e )
// If the swapper id is non-zero, then the page was not only loaded, but also bound, and possibly modified.
PageSwapper swapper = swappers.getAllocation( swapperId ).swapper;
evictionEvent.setSwapper( swapper );

if ( isModified( pageRef ) )
{
unlockExclusive( pageRef );
flushEvent.done( e );
evictionEvent.threwException( e );
throw e;
FlushEvent flushEvent = evictionEvent.flushEventOpportunity().beginFlush( filePageId, pageRef, swapper );
try
{
long address = getAddress( pageRef );
long bytesWritten = swapper.write( filePageId, address );
explicitlyMarkPageUnmodifiedUnderExclusiveLock( pageRef );
flushEvent.addBytesWritten( bytesWritten );
flushEvent.addPagesFlushed( 1 );
flushEvent.done();
}
catch ( IOException e )
{
unlockExclusive( pageRef );
flushEvent.done( e );
evictionEvent.threwException( e );
throw e;
}
}
swapper.evicted( filePageId );
}
swapper.evicted( filePageId );
clearBinding( pageRef );
}

Expand Down

0 comments on commit 13bbefe

Please sign in to comment.