@@ -872,17 +872,11 @@ A repository must set its `$GIT_DIR/config` to configure reftable:
872
872
Layout
873
873
^^^^^^
874
874
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.
886
880
887
881
Log-only files use the `.log` extension, while ref-only and mixed ref
888
882
and log files use `.ref`. extension.
@@ -893,9 +887,9 @@ current files, one per line, in order, from oldest (base) to newest
893
887
894
888
....
895
889
$ 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
899
893
....
900
894
901
895
Readers must read `$GIT_DIR/reftable/tables.list` to determine which
@@ -940,7 +934,7 @@ new reftable and atomically appending it to the stack:
940
934
3. Select `update_index` to be most recent file's
941
935
`max_update_index + 1`.
942
936
4. 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`.
944
938
6. Copy `tables.list` to `tables.list.lock`, appending file from (5).
945
939
7. Rename `tables.list.lock` to `tables.list`.
946
940
@@ -993,7 +987,7 @@ prevents other processes from trying to compact these files.
993
987
should always be the case, assuming that other processes are adhering to
994
988
the locking protocol.
995
989
7. 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`.
997
991
8. Write the new stack to `tables.list.lock`, replacing `B` and `C`
998
992
with the file from (4).
999
993
9. Rename `tables.list.lock` to `tables.list`.
@@ -1005,6 +999,22 @@ This strategy permits compactions to proceed independently of updates.
1005
999
Each reftable (compacted or not) is uniquely identified by its name, so
1006
1000
open reftables can be cached by their name.
1007
1001
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
+
1008
1018
Alternatives considered
1009
1019
~~~~~~~~~~~~~~~~~~~~~~~
1010
1020
0 commit comments