Disk Space Management - laforge49/aatree GitHub Wiki

Here are the states for a disk block:

  1. available
  2. in-use
  3. release-pending

The operations on this state are:

  1. allocate some block. An available block is changed to in-use.
  2. initiate-release. An in-use block is changed to release-pending.
  3. complete-release. Zero or more blocks are changed from release-pending to available.

Available blocks are tracked using the *allocated* bit-map. The maximum size of the database then size of the disk blocks * the number of bits in the bit-map. When a block is allocated, the corresponding bit in the bit-map is set. And when the release of a block is complete, the corresponding bit is cleared.

Release-pending blocks are tracked in the *release-pending* aavector. This allows them to be aged before being made available--so that any long-running queries active at the time their release was initiated will have been completed. the assumption then is that there will be a time-limit on long-running queries. Each entry is in turn a vector containing the time of the release in milliseconds, the number of the transaction which performed the release and the position of the block that was released.

The bit-set used to track available blocks and the aavector tracking the release-pending blocks are accessible via dynamic vars, i.e. thread local variables that are only bound during a database update.