跳转到内容

故障排查

先在应用数据目录运行:

Terminal window
graft init
graft sql --db data.sqlite "SELECT 1;"

graft sql 需要显式 --db 和已有 .graft/

确保 SQLite transaction 已提交,再显式 stage 物理文件:

Terminal window
graft sql --db data.sqlite "INSERT INTO notes(body) VALUES ('hello');"
graft status

外部 SQLite 工具修改后:

Terminal window
sqlite3 data.sqlite "INSERT INTO notes(body) VALUES ('hello');"
graft add data.sqlite

graft add 会捕获已提交的 WAL frames,不需要手动 checkpoint。未提交的 transaction 不属于可暂存状态。

Graft 在替换物理 SQLite 文件前会取得 SQLite 锁、处理 WAL sidecars,并拒绝覆盖 仍有 active writer 的数据库。先提交或回滚 transaction,关闭写连接,再重试 checkout、switch、restore、pull 或 merge-continue。

binary file 总是 external。text file 在超过 files.inline_text_threshold 或 匹配 files.external_paths 时也会 external。

Terminal window
graft config get files.inline_text_threshold
graft config get files.external_paths
Terminal window
graft payload status HEAD
graft payload fetch --remote origin HEAD
graft audit --repair origin
Terminal window
graft status
graft conflicts --json
graft resolve --ours data.sqlite
graft resolve --theirs attachments/report.pdf
graft merge --continue -m "resolve merge"

中止:

Terminal window
graft merge --abort

credential 不放在 URI 中:

Terminal window
export AWS_ACCESS_KEY_ID="..."
export AWS_SECRET_ACCESS_KEY="..."
export AWS_REGION="auto"

R2 或 MinIO 需要 endpoint:

Terminal window
graft remote add origin 's3_compatible://bucket/prefix?endpoint=https://account.r2.cloudflarestorage.com'

设置 remote URL 需要的 token environment variable:

Terminal window
export GRAFT_REMOTE_TOKEN='grt_...'
graft ls-remote origin