Skip to content

Take a context into GetStorageName

Sami Hiltunen requested to merge smh-ctx-locator into master

Transactions currently rely on rewriting the relative path of a repository to implement snapshot isolation. This has the downside that the relative paths get a prefix such as '+gitaly/staging/xx/yy/...'. For large parts of the application this is not a problem the handlers are generally just accessing a repository at a given path. This is a leaky abstraction though as the prefix is not part of the relative path and it is visible to the handlers. This has an impact on code that operates directly on the relative path in some manner. This could be for example logging, using the relative path as a key, or operating directly on file paths.

The rewriting could be implemented transparently if we instead rewrite the storage directory's root path as seen by the transaction. Storage directory's path doesn't have a meaning unlike the relative path which is used to identify a repository.

This commit takes the first step towards that by wiring context into GetStorageName of Locator. The injected context allows us to later plug transaction scoped logic into Locator that returns the rewritten storage root of a transaction when attempting to access a given storage. This way we can wire the indirection through the entire application without having to touch each site generating storage paths separately.

The commit is large as we access locator to generate storage paths in many places, and we have to drill the context down into each of them. The commit simply wires the context through all call sites into GetStorageName.

Related Hide snapshot prefix from transactions (#6095)

Merge request reports

Loading