core: update index tail in repair

This commit is contained in:
Gary Rong 2025-05-04 15:43:26 +08:00
parent ec1616d6e0
commit 8777ba0b6a

View file

@ -163,6 +163,7 @@ func (indexer *txIndexer) repair(head uint64) {
// A crash may occur between the two delete operations, // A crash may occur between the two delete operations,
// potentially leaving dangling indexes in the database. // potentially leaving dangling indexes in the database.
// However, this is considered acceptable. // However, this is considered acceptable.
indexer.tail.Store(nil)
rawdb.DeleteTxIndexTail(indexer.db) rawdb.DeleteTxIndexTail(indexer.db)
rawdb.DeleteAllTxLookupEntries(indexer.db, nil) rawdb.DeleteAllTxLookupEntries(indexer.db, nil)
log.Warn("Purge transaction indexes", "head", head, "tail", *tail) log.Warn("Purge transaction indexes", "head", head, "tail", *tail)
@ -183,6 +184,7 @@ func (indexer *txIndexer) repair(head uint64) {
// Traversing the database directly within the transaction // Traversing the database directly within the transaction
// index namespace might be slow and expensive, but we // index namespace might be slow and expensive, but we
// have no choice. // have no choice.
indexer.tail.Store(nil)
rawdb.DeleteTxIndexTail(indexer.db) rawdb.DeleteTxIndexTail(indexer.db)
rawdb.DeleteAllTxLookupEntries(indexer.db, nil) rawdb.DeleteAllTxLookupEntries(indexer.db, nil)
log.Warn("Purge transaction indexes", "head", head, "cutoff", indexer.cutoff) log.Warn("Purge transaction indexes", "head", head, "cutoff", indexer.cutoff)
@ -196,6 +198,7 @@ func (indexer *txIndexer) repair(head uint64) {
// A crash may occur between the two delete operations, // A crash may occur between the two delete operations,
// potentially leaving dangling indexes in the database. // potentially leaving dangling indexes in the database.
// However, this is considered acceptable. // However, this is considered acceptable.
indexer.tail.Store(&indexer.cutoff)
rawdb.WriteTxIndexTail(indexer.db, indexer.cutoff) rawdb.WriteTxIndexTail(indexer.db, indexer.cutoff)
rawdb.DeleteAllTxLookupEntries(indexer.db, func(txhash common.Hash, blob []byte) bool { rawdb.DeleteAllTxLookupEntries(indexer.db, func(txhash common.Hash, blob []byte) bool {
n := rawdb.DecodeTxLookupEntry(blob, indexer.db) n := rawdb.DecodeTxLookupEntry(blob, indexer.db)