synchronized (flushLock)
{
/* the trim is done by group in order to save some CPU and IO bandwidth
* start the transaction then do a bunch of remove then commit
*/
ReplServerDBCursor cursor;
cursor = db.openDeleteCursor();
try
{
while ((size < 5000 ) && (!finished))
{
ChangeNumber changeNumber = cursor.nextChangeNumber();
if (changeNumber != null)
{
if ((!changeNumber.equals(lastChange))
&& (changeNumber.older(trimDate)))
{
size++;
cursor.delete();
}
else
{
firstChange = changeNumber;
finished = true;
}
}
else
finished = true;
}
cursor.close();
done = true;
}
catch (LockConflictException e)
{
cursor.abort();
if (tries == DEADLOCK_RETRIES)
{
// could not handle the Deadlock after DEADLOCK_RETRIES tries.
// shutdown the ReplicationServer.
shutdown = true;
throw (e);
}
}
catch (DatabaseException e)
{
// mark shutdown for this db so that we don't try again to
// stop it from cursor.close() or methods called by cursor.close()
shutdown = true;
cursor.abort();
throw (e);
}
}
}
}