Skip to content

Support write-ahead logging custom hooks

Sami Hiltunen requested to merge smh-log-custom-hooks into master

This MR adds support for setting custom hooks through the write-ahead log. This will later ensure the hooks are replicated as part of the log and that they are included in the WAL based backups.

The hooks are taken in the same TAR archive format as they are currently received by SetCustomHooks. The TAR archive itself may extract for example symbolic hooks and files that Gitaly does not have permission to operate on. This is a more general issue so these are not tested here as part of the TranscationManager tests.

To keep the implementation simpler for now, we assume the hooks are generally fairly small. The hooks TAR is loaded into memory and written to the database.

The custom hooks are stored in <repo>/wal/hooks/<log_index>. This enables supporting snapshot reads later as we can keep multiple versions of the hooks available. There's no logic to wire the hooks into the Git calls yet. This is left for later when we have a way to start a transaction, during which we'd decide which hooks to use for the transaction's snapshot. Eventually, we'll integrate these by wiring the snapshot details to the HookManager so it can execute the correct version of custom hooks.

While the log entries carrying the hooks are pruned, the hooks themselves are not yet pruned from the disk. This is left for later as well since we'd have to wait for all transactions to be done using the hooks before we can remove them. We'll add this functionality later once there is a way to start a transaction explicitly.

Closes #4737 (closed)

Edited by Sami Hiltunen

Merge request reports