* Flush the current value, including the margin, to disk.
*
* @param session the session
*/
public synchronized void flush(Session session) {
Session sysSession = database.getSystemSession();
if (session == null || !database.isSysTableLocked()) {
// this session may not lock the sys table (except if it already has locked it)
// because it must be committed immediately
// otherwise other threads can not access the sys table.
session = sysSession;
}
synchronized (session) {
// just for this case, use the value with the margin for the script
long realValue = value;
try {
value = valueWithMargin;
database.update(session, this);
} finally {
value = realValue;
}
if (session == sysSession) {
// if the system session is used,
// the transaction must be committed immediately
sysSession.commit(false);
}
}
}