Repository navigation
dot watch: empty applies loop between machines and rewrite the whole history index each time #14251
Replies: 2 comments 1 reply
|
Thanks for the detailed report. The IO half is addressed in #14249: an index rebuild now rewrites a I could not reproduce the empty-apply loop. Two watchers on one origin with a plain tracked directory go quiet after an edit propagates (origin commit count stays flat for 12s). Could you help narrow it down?
AI-assisted — Tool: Claude Code; model: anthropic/claude-sonnet-5-5; version: claude-code_2-1-293_agent. |
|
Thanks for #14249. I found the trigger for the loop: an encrypted tracked file. Your test used a plain directory, which is why it went quiet. Here is a reproduction: two isolated homes, a local bare origin, one encrypted file, no edits, stepped with repro.sh#!/usr/bin/env bash
# Two machines on one origin, one encrypted tracked file, no edits.
# Each `dot watch --once` cycle on a machine that has an incoming change
# applies 0 changes but publishes before-apply/merge/apply commits, and the
# other machine sees them as one incoming change. Requires mise, git, age-keygen.
# Usage: repro.sh [mise-binary] [rounds] (ENCRYPT=no for the control run)
# OLD=<older mise> joins machine B and runs OLD_ROUNDS cycles with it first,
# so the machines diverge before switching to [mise-binary].
set -euo pipefail
MISE=${1:-mise}; ROUNDS=${2:-5}; ENCRYPT=${ENCRYPT:-yes}
OLD=${OLD:-$MISE}; OLD_ROUNDS=${OLD_ROUNDS:-0}; BIN=$OLD
R=$(mktemp -d); trap 'echo "left in $R"' EXIT
m() { local h="$R/$1"; shift; (cd "$h" && env -i HOME="$h" PATH="$PATH" \
XDG_CONFIG_HOME="$h/.config" XDG_STATE_HOME="$h/.local/state" \
XDG_DATA_HOME="$h/.local/share" XDG_CACHE_HOME="$h/.cache" "$BIN" "$@"); }
count() { git -C "$R/origin.git" rev-list --count history; }
git init -q --bare "$R/origin.git"
age-keygen -o "$R/key.txt" 2>/dev/null
PUB=$(grep -o 'age1[0-9a-z]*' "$R/key.txt")
for X in A B; do
mkdir -p "$R/$X/.config/mise/conf.d"
install -m 600 "$R/key.txt" "$R/$X/.config/mise/age.txt"
printf '[settings.history]\nsync = "sync"\n' > "$R/$X/.config/mise/config.local.toml"
done
P="$R/A/.config/mise/conf.d/dotfiles.toml"
printf '[history.encryption]\nrecipients = ["%s"]\n\n[dotfiles]\n' "$PUB" > "$P"
echo '"~/.config/mise/conf.d/dotfiles.toml" = { mode = "track" }' >> "$P"
echo '"~/plain.txt" = { mode = "track" }' >> "$P"
echo plain > "$R/A/plain.txt"
if [ "$ENCRYPT" = yes ]; then
echo '"~/secret.json" = { mode = "track", encrypt = true }' >> "$P"
echo '{"token":"x"}' > "$R/A/secret.json"
fi
m A dot origin set "$R/origin.git" --branch history --sync sync --yes >/dev/null 2>&1
m B dot origin set "$R/origin.git" --branch history --sync sync --yes >/dev/null 2>&1
m B dot pull --take-remote-all --yes >/dev/null 2>&1
echo "joined with $("$BIN" --version 2>/dev/null | head -1), encrypt=$ENCRYPT; origin commits: $(count)"
for i in $(seq 1 "$OLD_ROUNDS"); do
for X in A B; do m "$X" dot watch --once >/dev/null 2>&1; done
echo "old round $i: origin commits $(count)"
done
BIN=$MISE; echo "running $("$BIN" --version 2>/dev/null | head -1)"
for i in $(seq 1 "$ROUNDS"); do
for X in A B; do m "$X" dot watch --once >/dev/null 2>&1; done
echo "round $i: origin commits $(count)"
done
git -C "$R/origin.git" log history --format='%h %s' -n 6 | while read -r h s; do
echo "$h $s: $(git -C "$R/origin.git" diff --name-only "$h^1" "$h" 2>/dev/null | tr '\n' ' ')"
doneOn 2026.10.8, origin grows by three commits every cycle and never settles. The merge and apply commits change only the encrypted file: With On main (with #14300): a fresh setup stays quiet, because B no longer re-encrypts the file when it joins. But machines that already diverged keep looping after upgrading. Joining on 2026.10.8 and then switching both machines to a build of main at 88060c3: That matches the capture code on main: in Answers to your questions:
One local detail: our history repos mark encrypted paths The loop also left our branch at about 24,900 commits, which makes AI-assisted — Tool: Claude Code; model: anthropic/claude-opus-5-5; version: 2.1.296. |
Uh oh!
There was an error while loading. Please reload this page.
Summary
With
history.sync = "sync"on several machines sharing one origin, themise dot watchwatchers never go quiet. An apply that has nothing to apply still makes commits, every other machine counts those commits as an incoming change, and the cycle repeats indefinitely. Each apply also rewrites every file in the history index with fsync, so disk writes grow with the size of the history.On one machine this reached about 2 TB written in two days (about 12 to 20 MB/s sustained) and kept the watcher in uninterruptible IO most of the time.
Version
mise 2026.9.16 linux-x64 on all machines. I found nothing in the 2026.9.17 to 2026.10.6 release notes that addresses this; #14066 changes only the message.
Setup
mise dot watchas a systemd user service.history.sync = "sync",history.sync_interval = "30s",history.fetch_interval = "60s".What happens
applied 0 incoming change(s); 0 path(s) held for a decision, but still creates abefore applycommit, anapply: applied 0 incoming change(s)commit and amerge origin dotfilescommit, then publishes them.The incoming
apply: applied 0commits from other machines change no files (git show --statis empty). TheirMise-Historytrailer records"affected":[]and"applied"pointing at the other machine's previous apply commit.Over two and a half days the shared branch gained about 1,150
apply: applied 0commits, 1,150before applycommits and 1,350 merges, against about a dozen real edits. The loop had been running since the machines were enrolled, at 300 to 1,600 empty apply commits a day.Journal pattern on each machine:
Why it costs so much IO
After each apply, the watcher rewrites every file in
$MISE_STATE_DIR/history/index/meta/(one JSON file per checkpoint, about 24,000 files, about 556 MB) through a temp file, rename and fsync. I copied one meta file and compared it after the next pass: byte-identical. A full pass took about 7 minutes. On btrfs the process sat in D state inwait_log_commit,folio_wait_bit_commonandwrite_all_supers, and/proc/pressure/ioshowed about 30 to 45% full.Because the loop adds checkpoints and every pass rewrites all of them, the cost per cycle keeps growing. While a pass runs,
mise dot savefails withanother history operation is running.Related oddity
On the local machine, some commits labelled
apply: applied 0 incoming change(s)do contain local edits (for example a trackedSKILL.mdchange with 12 insertions). The label hides real changes inmise dot history.Expected
Workaround
Stop the watcher on every machine and use
mise dot save && mise dot syncby hand. Stopping it on one machine is not enough while two others keep running.All reactions