@Test
  public void flushing_pages_with_specific_pageio_must_not_race_with_eviction() throws Exception {
    // The idea is that we repeatedly load a page with an EXCLUSIVE lock, and unpin it so it can
    // be evicted. As soon as we have unpinned, we repeatedly try to flush it with our given
    // PageIO. If this causes an exception to be thrown, then we've raced with the eviction
    // where we shouldn't.
    PageSwapper io = new BufferPageSwapper(ByteBuffer.allocate(TEST_PAGE_SIZE));
    long pageId = 12;

    PinnablePage page = table.load(io, pageId, PageLock.EXCLUSIVE);
    monitor.observe(Fault.class);
    page.unpin(PageLock.EXCLUSIVE); // eviction is now possible
    LockSupport.unpark(sweeperThread);

    while (monitor.tryObserve(Evict.class) == null) {
      table.flush(io);
    }
  }