Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tail lock revisited #1328

Merged
merged 7 commits into from
Sep 2, 2024
Merged

Tail lock revisited #1328

merged 7 commits into from
Sep 2, 2024

Conversation

ceyonur
Copy link
Collaborator

@ceyonur ceyonur commented Aug 31, 2024

Why this should be merged

There is a potential race between txindexer and state sync (ResetToStateSyncedBlock/repairTxIndexTail), where reading can occur before repairTxIndexTail (which can increment the tail) and txindexer can work on an outdate tail (less than actual).

How this works

Uses txindexer's run function after grabbing lock and then do the actual db read for tail for run.

How this was tested

Not sure how to test this race

How is this documented

no need

@ceyonur ceyonur self-assigned this Aug 31, 2024
@ceyonur ceyonur requested review from darioush and a team as code owners August 31, 2024 19:01
@ceyonur ceyonur linked an issue Sep 2, 2024 that may be closed by this pull request
core/blockchain.go Outdated Show resolved Hide resolved
core/txindexer.go Show resolved Hide resolved
core/txindexer.go Show resolved Hide resolved
@ceyonur ceyonur requested a review from ARR4N September 2, 2024 12:43
@@ -159,15 +155,19 @@ func (indexer *txIndexer) loop(chain *BlockChain) {
stop = make(chan struct{})
done = make(chan struct{})
indexer.chain.wg.Add(1)
go indexer.run(rawdb.ReadTxIndexTail(indexer.db), head.Block.NumberU64(), stop, done)
go func() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this must always be the same as the equivalent go routine then consider abstracting it into shared code, otherwise all LGTM.

@ceyonur ceyonur merged commit e407ce4 into geth-v1.13.14-sq Sep 2, 2024
12 checks passed
@ceyonur ceyonur deleted the tail-lock-revisited branch September 2, 2024 14:32
ceyonur added a commit that referenced this pull request Sep 2, 2024
* all changes from v.13.2-x branch

* squash initial changes

* remove unneeded files

* fix lint

* gas estimation fix

* accounts/keystore: fix test with sleep

* rpc fixes

* try with a smaller limit

* logging

* change the trim fn

* remove main_test from rpc

* txpool: remove unused "PendingFrom"

* set local-txs-enabled in load tests

* ready to format

* format: remove upstream go-ethereum

* format: rename packages as fork

* Revert "format: remove avalanche header"

This reverts commit 09d505bd5e906ac186643061437e665b116b5bf6.

* fix logging

* deadcode linting

* more linting

* fix mock

* fix unused

* expecteds

* passing UTs

* add comment

* unused

* resolve some open issues

* undo script change

* test resillience

* fix compile

* wip

* test is fixed

* fix expecteds

* nits

* fix merge

* remove todos

* try

* try

* try

* docker stuff

* fix

* does this work

* fix

* hardcode for now

* fix

* hardcode for now

* remove TODO comments

* fix

* make txindexer more similar to upstream

* peer/network: move ctx check

* enforce tips in miner

* align nits with arr4n

* remove use of deprecated type core.GenesisAccount

* Revert "peer/network: move ctx check"

This reverts commit 147da5f.

* fix ctx check

* fix ctx again

* undo vm_test changes

* reduce diffs with ARR4N's branch

* update for enforcing gasTip

* unbuffer chan

* update to use commit(true)

* use TestOnlyAllowDuplicateBlocks

* Revert "update to use commit(true)"

This reverts commit 71d949e.

* overflow in state_transition err

* add http body limit flag (#1327)

* Tail lock revisited (#1328)

* avoid modifying the pointer

* improve readability

* prevent race in tail reading

* improve repairTxIndexTail readability

* use shared func

---------

Co-authored-by: Ceyhun Onur <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

check tailIndex lock in blockchain.go / txindexer
2 participants