}
// close all open containers and 'onCommit' objects of this container
t.notifyObservers(ckey);
RawContainerHandle containerHdl = (RawContainerHandle)
t.openContainer(ckey, cl, ContainerHandle.MODE_FORUPDATE);
// If container is already dropped or is no longer there, throw
// containerVanished exception unless container is temporary, in that
// case just return. Upper layer is supposed to prevent such from
// happening thru some means other than the lock we are getting here.
try
{
if (containerHdl == null ||
containerHdl.getContainerStatus() != RawContainerHandle.NORMAL)
{
// If we are a temp container, don't worry about it.
if (tmpContainer)
{
if (containerHdl != null)
containerHdl.removeContainer((LogInstant)null);
return;
}
else
{
throw StandardException.newException(
SQLState.DATA_CONTAINER_VANISHED, ckey);
}
}
// Container exist, is updatable and we got the lock.
if (tmpContainer)
{
containerHdl.dropContainer((LogInstant)null, true);
containerHdl.removeContainer((LogInstant)null);
}
else
{
ContainerOperation lop =
new ContainerOperation(
containerHdl, ContainerOperation.DROP);
// mark the container as pre-dirtied so that if a checkpoint
// happens after the log record is sent to the log stream, the
// cache cleaning will wait for this change.
containerHdl.preDirty(true);
try
{
t.logAndDo(lop);
}
finally
{
// in case logAndDo fail, make sure the container is not
// stuck in preDirty state.
containerHdl.preDirty(false);
}
// remember this as a post commit work item
Serviceable p =
new ReclaimSpace(
ReclaimSpace.CONTAINER,
ckey,
this,
true /* service ASAP */);
if (SanityManager.DEBUG)
{
if (SanityManager.DEBUG_ON(DaemonService.DaemonTrace))
{
SanityManager.DEBUG(
DaemonService.DaemonTrace,
"Add post commit work " + p);
}
}
t.addPostCommitWork(p);
}
}
finally
{
if (containerHdl != null)
containerHdl.close();
}
}