Track open transactions in TransactionManager
As described in &8903 (comment 1139370390), the pruning old data needs to be synchronized with open transactions accessing the repository. This is necessary:
- Supporting snapshot reads requires us to keep old versions around until no transaction needs them. This means we need to keep around the custom hooks, references and so on until there are no transactions that have them in their snapshot.
- The pack files in the log are based on a certain set of references. We need to ensure the objects in the repository the reference changes and the pack files in the log rely on are kept around until the log entries are applied. We'll do this by keeping internal references to past tips of the references. The internal references can be pruned after no transaction is using them
To support the above, TransactionManager
needs to support opening and closing a transaction. When a transaction is opened, it's assigned it's snapshot version which is a log index in the WAL. The TransactionManager
keeps track of open transactions and does not prune data related to loge entries that are equal to or later than the lowest log index needed by any open transaction. This ensures all the required data is kept in place.