| 228 | } |
| 229 | |
| 230 | func findFirstInvalidTxn(db *badger.DB, lowTs, highTs uint64) uint64 { |
| 231 | fmt.Println() |
| 232 | if highTs-lowTs < 1 { |
| 233 | fmt.Printf("Checking at lowTs: %d\n", lowTs) |
| 234 | if total := seekTotal(db, lowTs); total != 100 { |
| 235 | fmt.Printf("==> VIOLATION at ts: %d\n", lowTs) |
| 236 | return lowTs |
| 237 | } |
| 238 | fmt.Printf("No violation found at ts: %d\n", lowTs) |
| 239 | return 0 |
| 240 | } |
| 241 | |
| 242 | midTs := (lowTs + highTs) / 2 |
| 243 | fmt.Printf("Checking. low=%d. high=%d. mid=%d\n", lowTs, highTs, midTs) |
| 244 | if total := seekTotal(db, midTs); total == 100 { |
| 245 | // If no failure, move to higher ts. |
| 246 | return findFirstInvalidTxn(db, midTs+1, highTs) |
| 247 | } |
| 248 | // Found an error. |
| 249 | return findFirstInvalidTxn(db, lowTs, midTs) |
| 250 | } |
| 251 | |
| 252 | func showAllPostingsAt(db *badger.DB, readTs uint64) { |
| 253 | txn := db.NewTransactionAt(readTs, false) |