Skip to content

Commit 5f1c2c2

Browse files
derrickstoleegitster
authored andcommitted
maintenance: add troubleshooting guide to docs
The 'git maintenance run' subcommand takes a lock on the object database to prevent concurrent processes from competing for resources. This is an important safety measure to prevent possible repository corruption and data loss. This feature can lead to confusing behavior if a user is not aware of it. Add a TROUBLESHOOTING section to the 'git maintenance' builtin documentation that discusses these tradeoffs. The short version of this section is that Git will not corrupt your repository, but if the list of scheduled tasks takes longer than an hour then some scheduled tasks may be dropped due to this object database collision. For example, a long-running "daily" task at midnight might prevent an "hourly" task from running at 1AM. The opposite is also possible, but less likely as long as the "hourly" tasks are much faster than the "daily" and "weekly" tasks. Helped-by: Junio C Hamano <[email protected]> Signed-off-by: Derrick Stolee <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ce7f30d commit 5f1c2c2

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

Documentation/git-maintenance.txt

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,50 @@ OPTIONS
173173
`maintenance.<task>.enabled` configured as `true` are considered.
174174
See the 'TASKS' section for the list of accepted `<task>` values.
175175

176+
177+
TROUBLESHOOTING
178+
---------------
179+
The `git maintenance` command is designed to simplify the repository
180+
maintenance patterns while minimizing user wait time during Git commands.
181+
A variety of configuration options are available to allow customizing this
182+
process. The default maintenance options focus on operations that complete
183+
quickly, even on large repositories.
184+
185+
Users may find some cases where scheduled maintenance tasks do not run as
186+
frequently as intended. Each `git maintenance run` command takes a lock on
187+
the repository's object database, and this prevents other concurrent
188+
`git maintenance run` commands from running on the same repository. Without
189+
this safeguard, competing processes could leave the repository in an
190+
unpredictable state.
191+
192+
The background maintenance schedule runs `git maintenance run` processes
193+
on an hourly basis. Each run executes the "hourly" tasks. At midnight,
194+
that process also executes the "daily" tasks. At midnight on the first day
195+
of the week, that process also executes the "weekly" tasks. A single
196+
process iterates over each registered repository, performing the scheduled
197+
tasks for that frequency. Depending on the number of registered
198+
repositories and their sizes, this process may take longer than an hour.
199+
In this case, multiple `git maintenance run` commands may run on the same
200+
repository at the same time, colliding on the object database lock. This
201+
results in one of the two tasks not running.
202+
203+
If you find that some maintenance windows are taking longer than one hour
204+
to complete, then consider reducing the complexity of your maintenance
205+
tasks. For example, the `gc` task is much slower than the
206+
`incremental-repack` task. However, this comes at a cost of a slightly
207+
larger object database. Consider moving more expensive tasks to be run
208+
less frequently.
209+
210+
Expert users may consider scheduling their own maintenance tasks using a
211+
different schedule than is available through `git maintenance start` and
212+
Git configuration options. These users should be aware of the object
213+
database lock and how concurrent `git maintenance run` commands behave.
214+
Further, the `git gc` command should not be combined with
215+
`git maintenance run` commands. `git gc` modifies the object database
216+
but does not take the lock in the same way as `git maintenance run`. If
217+
possible, use `git maintenance run --task=gc` instead of `git gc`.
218+
219+
176220
GIT
177221
---
178222
Part of the linkgit:git[1] suite

0 commit comments

Comments
 (0)