@@ -872,17 +872,11 @@ A repository must set its `$GIT_DIR/config` to configure reftable:
872872Layout
873873^^^^^^
874874
875- A collection of reftable files are stored in the `$GIT_DIR/reftable/`
876- directory:
877-
878- ....
879- 00000001-00000001.log
880- 00000002-00000002.ref
881- 00000003-00000003.ref
882- ....
883-
884- where reftable files are named by a unique name such as produced by the
885- function `${min_update_index}-${max_update_index}.ref`.
875+ A collection of reftable files are stored in the `$GIT_DIR/reftable/` directory.
876+ Their names should have a random element, such that each filename is globally
877+ unique; this helps avoid spurious failures on Windows, where open files cannot
878+ be removed or overwritten. It suggested to use
879+ `${min_update_index}-${max_update_index}-${random}.ref` as a naming convention.
886880
887881Log-only files use the `.log` extension, while ref-only and mixed ref
888882and log files use `.ref`. extension.
@@ -893,9 +887,9 @@ current files, one per line, in order, from oldest (base) to newest
893887
894888....
895889$ cat .git/reftable/tables.list
896- 00000001-00000001.log
897- 00000002-00000002.ref
898- 00000003-00000003.ref
890+ 00000001-00000001-RANDOM1 .log
891+ 00000002-00000002-RANDOM2 .ref
892+ 00000003-00000003-RANDOM3 .ref
899893....
900894
901895Readers must read `$GIT_DIR/reftable/tables.list` to determine which
@@ -940,7 +934,7 @@ new reftable and atomically appending it to the stack:
9409343. Select `update_index` to be most recent file's
941935`max_update_index + 1`.
9429364. Prepare temp reftable `tmp_XXXXXX`, including log entries.
943- 5. Rename `tmp_XXXXXX` to `${update_index}-${update_index}.ref`.
937+ 5. Rename `tmp_XXXXXX` to `${update_index}-${update_index}-${random} .ref`.
9449386. Copy `tables.list` to `tables.list.lock`, appending file from (5).
9459397. Rename `tables.list.lock` to `tables.list`.
946940
@@ -993,7 +987,7 @@ prevents other processes from trying to compact these files.
993987should always be the case, assuming that other processes are adhering to
994988the locking protocol.
9959897. Rename `${min_update_index}-${max_update_index}_XXXXXX` to
996- `${min_update_index}-${max_update_index}.ref`.
990+ `${min_update_index}-${max_update_index}-${random} .ref`.
9979918. Write the new stack to `tables.list.lock`, replacing `B` and `C`
998992with the file from (4).
9999939. Rename `tables.list.lock` to `tables.list`.
@@ -1005,6 +999,22 @@ This strategy permits compactions to proceed independently of updates.
1005999Each reftable (compacted or not) is uniquely identified by its name, so
10061000open reftables can be cached by their name.
10071001
1002+ Windows
1003+ ^^^^^^^
1004+
1005+ On windows, and other systems that do not allow deleting or renaming to open
1006+ files, compaction may succeed, but other readers may prevent obsolete tables
1007+ from being deleted.
1008+
1009+ On these platforms, the following strategy can be followed: on closing a
1010+ reftable stack, reload `tables.list`, and delete any tables no longer mentioned
1011+ in `tables.list`.
1012+
1013+ Irregular program exit may still leave about unused files. In this case, a
1014+ cleanup operation can read `tables.list`, note its modification timestamp, and
1015+ delete any unreferenced `*.ref` files that are older.
1016+
1017+
10081018Alternatives considered
10091019~~~~~~~~~~~~~~~~~~~~~~~
10101020
0 commit comments