From d689f3bb1f580fff6cea911932e9861beee8fcbc Mon Sep 17 00:00:00 2001 From: buddho Date: Tue, 24 Jun 2025 15:29:26 +0800 Subject: [PATCH 1/2] core: warm key TransactionIndexTail by writing (#3196) --- core/txindexer.go | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/core/txindexer.go b/core/txindexer.go index 293124f681..effb0499d0 100644 --- a/core/txindexer.go +++ b/core/txindexer.go @@ -127,14 +127,30 @@ func (indexer *txIndexer) loop(chain *BlockChain) { // Listening to chain events and manipulate the transaction indexes. var ( - stop chan struct{} // Non-nil if background routine is active. - done chan struct{} // Non-nil if background routine is active. - lastHead uint64 // The latest announced chain head (whose tx indexes are assumed created) - lastTail = rawdb.ReadTxIndexTail(indexer.db) // The oldest indexed block, nil means nothing indexed - - headCh = make(chan ChainHeadEvent) - sub = chain.SubscribeChainHeadEvent(headCh) + stop chan struct{} // Non-nil if background routine is active. + done chan struct{} // Non-nil if background routine is active. + lastHead uint64 // The latest announced chain head (whose tx indexes are assumed created) + headCh = make(chan ChainHeadEvent) + sub = chain.SubscribeChainHeadEvent(headCh) ) + + lastTail := rawdb.ReadTxIndexTail(indexer.db) + if lastTail != nil { + // NOTE: The "TransactionIndexTail" key may exist only in cold SST files. + // Without a recent write, the key won't be in the memtable or block cache, + // causing every Get to trigger expensive readBlock + CRC checks. + // + // This dummy write forces the key into the memtable (and later SST), + // ensuring future reads are fast (from memory or block cache). + batch := indexer.db.NewBatch() + rawdb.WriteTxIndexTail(batch, *lastTail) + + if err := batch.Write(); err != nil { + log.Crit("Failed to write TransactionIndexTail warm-up", "error", err) + return + } + } + defer sub.Unsubscribe() // Launch the initial processing if chain is not empty (head != genesis). From 7f3b56239bd1f73fd2a1b36becd3bb92a0729fe9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 18 Jul 2025 18:38:33 +0000 Subject: [PATCH 2/2] build(deps): bump golang.org/x/oauth2 from 0.24.0 to 0.27.0 Bumps [golang.org/x/oauth2](https://github.com/golang/oauth2) from 0.24.0 to 0.27.0. - [Commits](https://github.com/golang/oauth2/compare/v0.24.0...v0.27.0) --- updated-dependencies: - dependency-name: golang.org/x/oauth2 dependency-version: 0.27.0 dependency-type: indirect ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 76e63a7e92..14a654897c 100644 --- a/go.mod +++ b/go.mod @@ -305,7 +305,7 @@ require ( go.uber.org/zap v1.27.0 // indirect golang.org/x/mod v0.23.0 // indirect golang.org/x/net v0.38.0 // indirect - golang.org/x/oauth2 v0.24.0 // indirect + golang.org/x/oauth2 v0.27.0 // indirect golang.org/x/term v0.30.0 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20250115164207-1a7da9e5054f // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f // indirect diff --git a/go.sum b/go.sum index babf3d6bca..e4e91b4280 100644 --- a/go.sum +++ b/go.sum @@ -1381,8 +1381,8 @@ golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.24.0 h1:KTBBxWqUa0ykRPLtV69rRto9TLXcqYkeswu48x/gvNE= -golang.org/x/oauth2 v0.24.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= +golang.org/x/oauth2 v0.27.0 h1:da9Vo7/tDv5RH/7nZDz1eMGS/q1Vv1N/7FCrBhI9I3M= +golang.org/x/oauth2 v0.27.0/go.mod h1:onh5ek6nERTohokkhCD/y2cV4Do3fxFHFuAejCkRWT8= golang.org/x/perf v0.0.0-20180704124530-6e6d33e29852/go.mod h1:JLpeXjPJfIyPr5TlbXLkXWLhP8nz10XfvxElABhCtcw= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=