使用 git bisect 与 Ceph
在调查 一个问题 使用最新的 Ceph 源代码时,发现该问题仅出现在 master 分支中,并且在 v0.85 标签之后出现。以下脚本重现该问题并记录结果
$ cat try.sh #!/bin/bash cd src log=$(git describe) echo $log.log make -j4 >& $log.log rm -fr dev out ; mkdir -p dev MDS=1 MON=1 OSD=3 timeout 120 ./vstart.sh \ -o 'paxos propose interval = 0.01' \ -n -l mon osd mds >> $log.log 2>&1 status=$? ./stop.sh exit $status
可以使用 git bisect 找到问题首次出现时的修订版本。
$ git bisect start # 初始化搜索 $ git bad origin/master # 问题发生 $ git good tags/v0.85 # 问题没有发生 $ git bisect run try.sh # 在 tags/v0.85..origin/master 中进行二分搜索 运行 try.sh v0.85-679-g8d3f135.log Bisecting: 339 revisions left to test after this (roughly 8 steps) [ef006ae] Merge pull request #2658 from athanatos/wip-9625 运行 try.sh v0.86-27-gef006ae.log Bisecting: 169 revisions left to test after this (roughly 7 steps) [fa0bd06] ceph-disk: bootstrap-osd keyring ignores --statedir 运行 try.sh v0.85-1116-gfa0bd06.log ... v0.86-263-g5f6589c.log d15ecafea4 是第一个出现问题的提交 commit d15eca Author: John Spray Date: Fri Sep 26 17:24:12 2014 +0100 vstart: create fewer pgs for fs pools :040000 040000 f42a324a8 aa64cdc1ed3 M src bisect run success