int BinlogQueue::del_range(uint64_t start, uint64_t end){ while(start <= end){ leveldb::WriteBatch batch; for(int count = 0; start <= end && count < 1000; start++, count++){ batch.Delete(encode_seq_key(start)); } //這裏會實際刪除數據庫的數據,可是del_range會在binlog按期清理函數中調用 //問題:log_clean_thread_func的定位應該是清理min/last seq ,維護一個範圍而已,爲什麼要實際刪除數據呢?何況,set的kv值,在commit時候,實際寫入了db了(而後清理log時候再給刪除)?實在不明白! leveldb::Status s = db->Write(leveldb::WriteOptions(), &batch); if(!s.ok()){ return -1; } } return 0; }