This is an old revision of the document!


This page is for sharing the design and progress of the project to add transaction support to FreeBSD.

TableOfContents(3)

Overview

The objective of this project is to allow a process to start a transaction that can be later committed or aborted. This would allow, for example, the painless rollback of a port installation that failed in the middle.

Design

Transactions are based on snapshots. Each process gets an additional field, its transaction id, which gets as its value the process id that begins a transaction, and is inherited when a process forks. Nested transactions are not allowed. When a transaction begins, a snapshot file named after the transaction id is created on each of the specified filesystems. The snapshot code is modified so that when a block is overwritten, if the block has already been copied in the transaction's snapshot and the process modifying the block is not part of the corresponding transaction, then the corresponding call is blocked, waiting for the transaction to complete. Otherwise, the block is copied as usual.

When the transaction terminates (through a commit or abort) the transaction id of all processes of that transaction is cleared. If the transaction is committed, the snapshot file is released and deleted and waiting processes are notified. If the transaction is aborted, then the snapshot is suspended, all the snapshot's blocks are copied to the live filesystem, th ensapshot file is released, and then waiting processes are notified.

Periodicaly a reaper thread looks for active transactions with no corresponding running processes, and aborts them.

API

  • int transaction(int request, …)
    • TR_BEGIN, char **transacted_filesystems
    • TR_COMMIT
    • TR_ABORT
    • TR_GETID
  • All geted system calls can return E_TRVIOL (Transaction violation): a transaction attempted to modify data on a filesystem that is not under transaction control.

transaction -b filesystem … | -c | -a | -g

Progress

  • Rough design overview (dds - 2007-06-22)
  • API documentation, design refinement (dds - 2007-06-23)

TODO

  • Any issues with deleted and allocated blocks?

References

  • transactions.1182667576.txt.gz
  • Last modified: 2007/06/24 06:46
  • by DiomidisSpinellis