go-ethereum/core/rawdb
Martin Holst Swende 9b99e3dfe0
core/rawdb: fix datarace in freezer (#22728)
The Append / truncate operations were racy. When a datafile reaches 2Gb, a new file is needed. For this operation, we require a writelock, which is not needed in the 99.99% of all cases where the data does fit in the current head-file.

This transition from readlock to writelock was incorrect, and as the readlock was released, a truncate operation could slip in between, and truncate the data. This would have been fine, however, the Append operation continued writing as if no truncation had occurred, e.g writing item 5 where item 0 should reside.

This PR changes the behaviour, so that if when we run into the situation that a new file is needed, it aborts, and retries, this time with a writelock.

The outcome of the situation described above, running on this PR, would instead be that the Append operation exits with a failure.
2021-04-26 18:19:07 +02:00
..
accessors_chain_test.go all: add read-only option to database (#22407) 2021-03-22 19:06:30 +01:00
accessors_chain.go all: add read-only option to database (#22407) 2021-03-22 19:06:30 +01:00
accessors_indexes_test.go core/rawdb: single point of maintenance for writing and deleting tx lookup indexes (#21480) 2020-09-15 10:37:01 +02:00
accessors_indexes.go core/rawdb: single point of maintenance for writing and deleting tx lookup indexes (#21480) 2020-09-15 10:37:01 +02:00
accessors_metadata.go core, eth, les: implement unclean-shutdown marker (#21893) 2020-12-11 15:56:00 +01:00
accessors_snapshot.go core/rawdb, eth/protocols : Method name typo fix (#22026) 2020-12-27 22:38:16 +01:00
accessors_state.go core, eth, les, trie: add a prefix to contract code (#21080) 2020-08-21 15:10:40 +03:00
chain_iterator_test.go core/rawdb: fix transaction indexing/unindexing hashing error (#22457) 2021-03-16 12:15:14 +02:00
chain_iterator.go core/rawdb: fix transaction indexing/unindexing hashing error (#22457) 2021-03-16 12:15:14 +02:00
database.go all: add read-only option to database (#22407) 2021-03-22 19:06:30 +01:00
freezer_table_test.go core/rawdb: fix datarace in freezer (#22728) 2021-04-26 18:19:07 +02:00
freezer_table.go core/rawdb: fix datarace in freezer (#22728) 2021-04-26 18:19:07 +02:00
freezer.go cmd/geth: add db-command to inspect freezer index (#22633) 2021-04-13 15:45:30 +02:00
schema.go cmd/geth: add db-command to inspect freezer index (#22633) 2021-04-13 15:45:30 +02:00
table_test.go all: simplify and fix database iteration with prefix/start (#20808) 2020-04-15 14:08:53 +03:00
table.go all: simplify and fix database iteration with prefix/start (#20808) 2020-04-15 14:08:53 +03:00