Top Description Fields Constructors Methods
org.apache.derby.impl.store.access.btree

pack-priv Class BTreePostCommit

extends Object
implements Serviceable
Class Inheritance
All Implemented Interfaces
org.apache.derby.iapi.services.daemon.Serviceable
Imports
org.apache.derby.iapi.services.context.ContextManager, org.apache.derby.iapi.services.daemon.Serviceable, org.apache.derby.shared.common.sanity.SanityManager, org.apache.derby.shared.common.error.StandardException, org.apache.derby.iapi.store.access.AccessFactory, .AccessFactoryGlobals, .ConglomerateController, .DynamicCompiledOpenConglomInfo, .RowUtil, .TransactionController, org.apache.derby.iapi.store.access.conglomerate.LogicalUndo, .TransactionManager, org.apache.derby.iapi.store.raw.ContainerHandle, .FetchDescriptor, .LockingPolicy, .Page, .RecordHandle, org.apache.derby.iapi.types.DataValueDescriptor, org.apache.derby.shared.common.reference.SQLState

The BTreePostCommit class implements the Serviceable protocol. In it's role as a Serviceable object, it stores the state necessary to find a page in a btree that may have committed delete's to reclaim. In it's role as a PostCommitProcessor it looks up the page described, and reclaims space in the btree. It first trys to clean up any deleted commits on the page. It then will shrink the tree if it is going to delete all rows from the page (RESOLVE - not done yet).

Field Summary

Modifier and TypeField and Description
private AccessFactory
protected BTree
private long

Constructor Summary

AccessConstructor and Description
pack-priv
BTreePostCommit(AccessFactory access_factory, BTree btree, long input_page_number)

Method Summary

Modifier and TypeMethod and Description
private final void
doShrink(OpenBTree open_btree, DataValueDescriptor[] shrink_row)

private final DataValueDescriptor[]
getShrinkKey(OpenBTree open_btree, ControlRow control_row, int slot_no)

private final OpenBTree
openIndex(TransactionManager internal_xact, int
For table level use TransactionManager.MODE_TABLE, for row level use TransactionManager.MODE_RECORD
lock_level
,
int
For table level use LockingPolicy.MODE_CONTAINER, for row level use LockingPolicy.MODE_RECORD
lock_mode
)

Open index for either table level or row level update.

public int

Returns:

Returns Serviceable.DONE when work has completed, or returns Serviceable.REQUEUE if work needs to be requeued.
performWork
(ContextManager
the context manager started by the post commit daemon
contextMgr
)

Implements org.apache.derby.iapi.services.daemon.Serviceable.performWork.

perform the work described in the postcommit work.

private final DataValueDescriptor[]
purgeCommittedDeletes(OpenBTree
The btree already opened.
open_btree
,
long
The page number of the page to look for committed deletes.
pageno
)

Reclaim space taken up by committed deleted rows.

private final void
purgeRowLevelCommittedDeletes(OpenBTree
The already open btree, which has been locked with IX table lock, to use to get latch on page.
open_btree
)

Attempt to reclaim committed deleted rows from the page with row locking.

public boolean

Returns:

false, this work should not be serviced ASAP
serviceASAP
()

Implements org.apache.derby.iapi.services.daemon.Serviceable.serviceASAP.

The urgency of this post commit work.

public boolean
serviceImmediately()

Implements org.apache.derby.iapi.services.daemon.Serviceable.serviceImmediately.

If this work should be done immediately on the user thread then return true.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

access_factoryback to summary
private AccessFactory access_factory
btreeback to summary
protected BTree btree
page_numberback to summary
private long page_number

Constructor Detail

BTreePostCommitback to summary
pack-priv BTreePostCommit(AccessFactory access_factory, BTree btree, long input_page_number)

Method Detail

doShrinkback to summary
private final void doShrink(OpenBTree open_btree, DataValueDescriptor[] shrink_row) throws StandardException
getShrinkKeyback to summary
private final DataValueDescriptor[] getShrinkKey(OpenBTree open_btree, ControlRow control_row, int slot_no) throws StandardException
openIndexback to summary
private final OpenBTree openIndex(TransactionManager internal_xact, int lock_level, int lock_mode) throws StandardException

Open index for either table level or row level update.

Parameters
lock_level:int

For table level use TransactionManager.MODE_TABLE, for row level use TransactionManager.MODE_RECORD

lock_mode:int

For table level use LockingPolicy.MODE_CONTAINER, for row level use LockingPolicy.MODE_RECORD

Exceptions
StandardException:
Standard exception policy.
performWorkback to summary
public int performWork(ContextManager contextMgr) throws StandardException

Implements org.apache.derby.iapi.services.daemon.Serviceable.performWork.

perform the work described in the postcommit work.

In this implementation the only work that can be executed by this post commit processor is this class itself.

Parameters
contextMgr:ContextManager

the context manager started by the post commit daemon

Returns:int

Returns Serviceable.DONE when work has completed, or returns Serviceable.REQUEUE if work needs to be requeued.

Exceptions
StandardException:
Standard exception policy.
purgeCommittedDeletesback to summary
private final DataValueDescriptor[] purgeCommittedDeletes(OpenBTree open_btree, long pageno) throws StandardException

Reclaim space taken up by committed deleted rows.

This routine assumes it has been called by an internal transaction which has performed no work so far, and that it has an exclusive table lock. These assumptions mean that any deleted rows encountered must be from committed transactions (otherwise we could not have gotten the exclusive table lock).

This routine handles purging committed deletes while holding a table level exclusive lock. See purgeRowLevelCommittedDeletes() for row level purging.

Parameters
open_btree:OpenBTree

The btree already opened.

pageno:long

The page number of the page to look for committed deletes.

Exceptions
StandardException:
Standard exception policy.
purgeRowLevelCommittedDeletesback to summary
private final void purgeRowLevelCommittedDeletes(OpenBTree open_btree) throws StandardException

Attempt to reclaim committed deleted rows from the page with row locking.

Get exclusive latch on page, and then loop backward through page searching for deleted rows which are committed. This routine is called only from post commit processing so it will never see rows deleted by the current transaction. For each deleted row on the page it attempts to get an exclusive lock on the deleted row, NOWAIT. If it succeeds, and since this transaction did not delete the row then the row must have been deleted by a transaction which has committed, so it is safe to purge the row. It then purges the row from the page.

The latch on the leaf page containing the purged rows must be kept until after the transaction has been committed or aborted in order to insure proper undo of the purges can take place. Otherwise another transaction could use the space freed by the purge and then prevent the purge from being able to undo.

Parameters
open_btree:OpenBTree

The already open btree, which has been locked with IX table lock, to use to get latch on page.

Exceptions
StandardException:
Standard exception policy.
serviceASAPback to summary
public boolean serviceASAP()

Implements org.apache.derby.iapi.services.daemon.Serviceable.serviceASAP.

The urgency of this post commit work.

This determines where this Serviceable is put in the post commit queue. Post commit work in the btree can be safely delayed until there is not user work to do.

Returns:boolean

false, this work should not be serviced ASAP

serviceImmediatelyback to summary
public boolean serviceImmediately()

Implements org.apache.derby.iapi.services.daemon.Serviceable.serviceImmediately.

Doc from org.apache.derby.iapi.services.daemon.Serviceable.serviceImmediately.

If this work should be done immediately on the user thread then return true. If it doesn't make any difference if this work is done on a the user thread immediately or if it is performed by another thread asynchronously later, then return false.

Returns:boolean

true if this work shold happen immediately on the user thread