microsoft / git

A fork of Git containing Microsoft-specific patches.
http://git-scm.com/
Other
784 stars 94 forks source link

unable to normalize alternate object path #618

Closed miku1958 closed 11 months ago

miku1958 commented 11 months ago

Setup

$ git --version --build-options

git version 2.42.0.vfs.0.3
cpu: x86_64
built from commit: 00315c66d6c46bfb868d4f02f9547d8255119def
sizeof-long: 8
sizeof-size_t: 8
shell-path: /bin/sh
feature: fsmonitor--daemon

Are you using Scalar or VFS for Git?

scalar

macOS 14.1.1 arm

Details

zsh

Most of git command will output unable to normalize alternate object path, tried to remove all objects under id_ba47400f-eebe-4850-a8bf-ef694ef81414 and run git maintenance run --task=prefetch and git reset --hard to re-fetch all object but it doesn't work.

$ git status
18:59:00.488355 common-main.c:55             | d0 | main                     | version      |     |           |           |              | 2.42.0.vfs.0.3
18:59:00.488805 common-main.c:56             | d0 | main                     | start        |     |  0.001458 |           |              | git status
18:59:00.489304 repository.c:143             | d0 | main                     | def_repo     | r1  |           |           |              | worktree:/Volumes/Office/monorepo.git/src
18:59:00.490274 git.c:536                    | d0 | main                     | cmd_name     |     |           |           |              | status (status)
18:59:00.490732 read-cache.c:2419            | d0 | main                     | region_enter | r1  |  0.003389 |           | index        | label:do_read_index .git/index
18:59:00.492570 read-cache.c:2066            | d0 | th01:load_index_extensio | thread_start |     |  0.005222 |           |              | 
18:59:00.492588 read-cache.c:1770            | d0 | th01:load_index_extensio | region_enter |     |  0.005246 |           | index        | label:read/extension/cache_tree
18:59:00.492599 cache-tree.c:669             | d0 | th01:load_index_extensio | region_enter | r1  |  0.005257 |           | cache_tree   | ..label:read
18:59:00.492605 read-cache.c:2149            | d0 | th02:load_cache_entries  | thread_start |     |  0.005255 |           |              | 
18:59:00.492805 read-cache.c:2149            | d0 | th05:load_cache_entries  | thread_start |     |  0.005461 |           |              | 
18:59:00.492853 read-cache.c:2149            | d0 | th07:load_cache_entries  | thread_start |     |  0.005492 |           |              | 
18:59:00.492873 read-cache.c:2149            | d0 | th08:load_cache_entries  | thread_start |     |  0.005530 |           |              | 
18:59:00.493072 read-cache.c:2149            | d0 | th11:load_cache_entries  | thread_start |     |  0.005661 |           |              | 
18:59:00.493118 read-cache.c:2149            | d0 | th12:load_cache_entries  | thread_start |     |  0.005734 |           |              | 
18:59:00.492658 read-cache.c:2149            | d0 | th03:load_cache_entries  | thread_start |     |  0.005290 |           |              | 
18:59:00.492699 read-cache.c:2149            | d0 | th04:load_cache_entries  | thread_start |     |  0.005336 |           |              | 
18:59:00.492904 read-cache.c:2149            | d0 | th09:load_cache_entries  | thread_start |     |  0.005561 |           |              | 
18:59:00.492939 read-cache.c:2149            | d0 | th10:load_cache_entries  | thread_start |     |  0.005597 |           |              | 
18:59:00.492814 read-cache.c:2149            | d0 | th06:load_cache_entries  | thread_start |     |  0.005470 |           |              | 
18:59:00.493360 read-cache.c:2149            | d0 | th13:load_cache_entries  | thread_start |     |  0.005899 |           |              | 
18:59:00.493757 read-cache.c:2149            | d0 | th14:load_cache_entries  | thread_start |     |  0.006306 |           |              | 
18:59:00.494549 read-cache.c:2149            | d0 | th15:load_cache_entries  | thread_start |     |  0.007103 |           |              | 
18:59:00.495395 read-cache.c:2149            | d0 | th16:load_cache_entries  | thread_start |     |  0.007946 |           |              | 
18:59:00.498208 read-cache.c:2158            | d0 | th14:load_cache_entries  | thread_exit  |     |  0.010864 |  0.004558 |              | 
18:59:00.498595 read-cache.c:2158            | d0 | th15:load_cache_entries  | thread_exit  |     |  0.011254 |  0.004151 |              | 
18:59:00.499122 read-cache.c:2158            | d0 | th16:load_cache_entries  | thread_exit  |     |  0.011780 |  0.003834 |              | 
18:59:00.504327 read-cache.c:2158            | d0 | th02:load_cache_entries  | thread_exit  |     |  0.016985 |  0.011730 |              | 
18:59:00.504886 read-cache.c:2158            | d0 | th05:load_cache_entries  | thread_exit  |     |  0.017544 |  0.012083 |              | 
18:59:00.505302 read-cache.c:2158            | d0 | th04:load_cache_entries  | thread_exit  |     |  0.017960 |  0.012624 |              | 
18:59:00.505374 read-cache.c:2158            | d0 | th07:load_cache_entries  | thread_exit  |     |  0.018033 |  0.012541 |              | 
18:59:00.505557 read-cache.c:2158            | d0 | th09:load_cache_entries  | thread_exit  |     |  0.018215 |  0.012654 |              | 
18:59:00.505619 read-cache.c:2158            | d0 | th06:load_cache_entries  | thread_exit  |     |  0.018277 |  0.012807 |              | 
18:59:00.505748 read-cache.c:2158            | d0 | th10:load_cache_entries  | thread_exit  |     |  0.018406 |  0.012809 |              | 
18:59:00.505758 read-cache.c:2158            | d0 | th03:load_cache_entries  | thread_exit  |     |  0.018416 |  0.013126 |              | 
18:59:00.505761 read-cache.c:2158            | d0 | th13:load_cache_entries  | thread_exit  |     |  0.018420 |  0.012521 |              | 
18:59:00.505766 read-cache.c:2158            | d0 | th12:load_cache_entries  | thread_exit  |     |  0.018424 |  0.012690 |              | 
18:59:00.505884 read-cache.c:2158            | d0 | th11:load_cache_entries  | thread_exit  |     |  0.018542 |  0.012881 |              | 
18:59:00.505991 read-cache.c:2158            | d0 | th08:load_cache_entries  | thread_exit  |     |  0.018650 |  0.013120 |              | 
18:59:00.506421 cache-tree.c:671             | d0 | th01:load_index_extensio | region_leave | r1  |  0.019078 |  0.013821 | cache_tree   | ..label:read
18:59:00.506447 read-cache.c:1772            | d0 | th01:load_index_extensio | data         |     |  0.019102 |  0.013856 | index        | ..read/extension/cache_tree/bytes:1242447
18:59:00.506453 read-cache.c:1773            | d0 | th01:load_index_extensio | region_leave |     |  0.019112 |  0.013866 | index        | label:read/extension/cache_tree
18:59:00.511577 fsmonitor.c:97               | d0 | th01:load_index_extensio | data         |     |  0.024234 |  0.019012 | index        | extension/fsmn/read/token:builtin:0.16506.20231115T075303.406403Z:359
18:59:00.511584 read-cache.c:2068            | d0 | th01:load_index_extensio | thread_exit  |     |  0.024243 |  0.019021 |              | 
18:59:00.512058 read-cache.c:2368            | d0 | main                     | data         | r1  |  0.024716 |  0.021327 | index        | ..read/version:4
18:59:00.512075 read-cache.c:2370            | d0 | main                     | data         | r1  |  0.024734 |  0.021345 | index        | ..read/cache_nr:179339
18:59:00.512315 read-cache.c:2424            | d0 | main                     | region_leave | r1  |  0.024968 |  0.021579 | index        | label:do_read_index .git/index
18:59:00.513026 fsmonitor-ipc.c:84           | d0 | main                     | region_enter |     |  0.025684 |           | fsm_client   | label:query
18:59:00.513043 fsmonitor-ipc.c:85           | d0 | main                     | data         |     |  0.025701 |  0.000017 | fsm_client   | ..query/command:builtin:0.16506.20231115T075303.406403Z:359
18:59:00.513053 ...ipc/ipc-unix-socket.c:164 | d0 | main                     | region_enter |     |  0.025711 |           | ipc-client   | ..label:try-connect
18:59:00.513058 ...ipc/ipc-unix-socket.c:165 | d0 | main                     | data         |     |  0.025716 |  0.000005 | ipc-client   | ....try-connect/path:.git/fsmonitor--daemon.ipc
18:59:00.513383 ...ipc/ipc-unix-socket.c:171 | d0 | main                     | data         |     |  0.026041 |  0.000330 | ipc-client   | ....try-connect/state:0
18:59:00.513391 ...ipc/ipc-unix-socket.c:172 | d0 | main                     | region_leave |     |  0.026050 |  0.000339 | ipc-client   | ..label:try-connect
18:59:00.513398 ...ipc/ipc-unix-socket.c:202 | d0 | main                     | region_enter |     |  0.026057 |           | ipc-client   | ..label:send-command
18:59:00.524974 ...ipc/ipc-unix-socket.c:219 | d0 | main                     | region_leave |     |  0.037632 |  0.011575 | ipc-client   | ..label:send-command
18:59:00.524986 fsmonitor-ipc.c:98           | d0 | main                     | data         |     |  0.037645 |  0.011961 | fsm_client   | ..query/response-length:44
18:59:00.524992 fsmonitor-ipc.c:135          | d0 | main                     | region_leave |     |  0.037651 |  0.011967 | fsm_client   | label:query
18:59:00.525002 fsmonitor.c:450              | d0 | main                     | region_enter | r1  |  0.037661 |           | fsmonitor    | label:apply_results
18:59:00.525007 fsmonitor.c:481              | d0 | main                     | data         | r1  |  0.037666 |  0.000005 | fsmonitor    | ..apply_count:0
18:59:00.525012 fsmonitor.c:511              | d0 | main                     | region_leave | r1  |  0.037671 |  0.000010 | fsmonitor    | label:apply_results
18:59:00.525028 sparse-index.c:506           | d0 | main                     | region_enter | r1  |  0.037687 |           | index        | label:clear_skip_worktree_from_present_files
18:59:00.530338 sparse-index.c:528           | d0 | main                     | data         | r1  |  0.042996 |  0.005309 | index        | ..sparse_path_count:2210
18:59:00.530358 sparse-index.c:533           | d0 | main                     | region_leave | r1  |  0.043017 |  0.005330 | index        | label:clear_skip_worktree_from_present_files
18:59:00.530389 progress.c:270               | d0 | main                     | region_enter | r1  |  0.043047 |           | progress     | label:Refresh index
18:59:00.530398 preload-index.c:125          | d0 | main                     | region_enter |     |  0.043057 |           | index        | ..label:preload
18:59:00.531203 preload-index.c:173          | d0 | main                     | data         |     |  0.043861 |  0.000804 | index        | ....preload/sum_lstat:0
18:59:00.531218 preload-index.c:174          | d0 | main                     | region_leave |     |  0.043877 |  0.000820 | index        | ..label:preload
18:59:00.531223 read-cache.c:1557            | d0 | main                     | region_enter |     |  0.043882 |           | index        | ..label:refresh
18:59:00.534641 read-cache.c:1639            | d0 | main                     | data         |     |  0.047300 |  0.003418 | index        | ....refresh/sum_lstat:0
18:59:00.534651 read-cache.c:1640            | d0 | main                     | data         |     |  0.047310 |  0.003428 | index        | ....refresh/sum_scan:0
18:59:00.534655 read-cache.c:1641            | d0 | main                     | region_leave |     |  0.047314 |  0.003432 | index        | ..label:refresh
18:59:00.534662 progress.c:342               | d0 | main                     | data         | r1  |  0.047321 |  0.004274 | progress     | ..total_objects:179339
18:59:00.534666 progress.c:348               | d0 | main                     | region_leave | r1  |  0.047325 |  0.004278 | progress     | label:Refresh index
18:59:00.535097 builtin/commit.c:1823        | d0 | main                     | cmd_mode     |     |           |           |              | collect
18:59:00.535104 wt-status.c:834              | d0 | main                     | region_enter | r1  |  0.047763 |           | status       | label:worktrees
18:59:00.537766 diffcore-rename.c:1405       | d0 | main                     | region_enter | r1  |  0.050424 |           | diff         | ..label:setup
18:59:00.537774 diffcore-rename.c:1458       | d0 | main                     | region_leave | r1  |  0.050433 |  0.000009 | diff         | ..label:setup
18:59:00.537779 diffcore-rename.c:1637       | d0 | main                     | region_enter | r1  |  0.050438 |           | diff         | ..label:write back to queue
18:59:00.537783 diffcore-rename.c:1714       | d0 | main                     | region_leave | r1  |  0.050442 |  0.000004 | diff         | ..label:write back to queue
18:59:00.537805 wt-status.c:836              | d0 | main                     | region_leave | r1  |  0.050464 |  0.002701 | status       | label:worktrees
18:59:00.537810 wt-status.c:843              | d0 | main                     | region_enter | r1  |  0.050469 |           | status       | label:index
18:59:00.538746 usage.c:80                   | d0 | main                     | error        |     |           |           |              | ..unable to normalize alternate object path: /Volumes/Builds/.scalarCache/id_ba47400f-eebe-4850-a8bf-ef694ef81414
error: unable to normalize alternate object path: /Volumes/Builds/.scalarCache/id_ba47400f-eebe-4850-a8bf-ef694ef81414
dscho commented 11 months ago

The error message "unable to normalize alternate object path" is produced here: https://github.com/microsoft/git/blob/b7dec5ad71dc527cca6550430ce40684a3b3d65a/object-file.c#L587

That's in a code path where an alternate object database needs to be accessed, but apparently cannot be. Could you see whether all the paths listed in .git\objects\info\alternates are valid and reachable? Or maybe there is something else that is curious about them?

Also, when I look at the code that produces the error message, it actually prints out more than just the error: it prints out the path that could not be normalized. Have you analyzed this shown path yet?

miku1958 commented 11 months ago

Thank you @dscho! I update the path in .git\objects\info\alternates and it is fixed! I copy the .scalarCache from other machine and they has different path.