Skip to content

Conversation

TheBlueMatt
Copy link
Contributor

The LevelDB docs seem to indicate that an iterator will not take
snapshots (even providing instructions on how to do so yourself).
In several of the places we use them, we assume snapshots to have
been taken.

In order to make sure LevelDB doesn't change out from under us
(and to prevent the next person who reads the docs from having the
same fright I did), verify that snapshots are taken in our tests.

Copy link
Member

@sipa sipa left a comment

Choose a reason for hiding this comment

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

utACK

@@ -204,19 +204,33 @@ BOOST_AUTO_TEST_CASE(iterator_ordering)
for (int x=0x00; x<256; ++x) {
uint8_t key = x;
uint32_t value = x*x;
BOOST_CHECK(dbw.Write(key, value));
if (!(x & 1))
Copy link
Member

Choose a reason for hiding this comment

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

Can I haz braces before indenting?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, but I fixed it anyway :p.

@mess110
Copy link
Contributor

mess110 commented Sep 29, 2017

edit: ACK bb8376b

@maflcko maflcko changed the title Verify DBWrapper iterators are taking snapshots qa: Verify DBWrapper iterators are taking snapshots Sep 30, 2017
@maflcko maflcko added the Tests label Sep 30, 2017
The LevelDB docs seem to indicate that an iterator will not take
snapshots (even providing instructions on how to do so yourself).
In several of the places we use them, we assume snapshots to have
been taken.

In order to make sure LevelDB doesn't change out from under us
(and to prevent the next person who reads the docs from having the
same fright I did), verify that snapshots are taken in our tests.
@TheBlueMatt TheBlueMatt force-pushed the 2017-09-leveldb-check-snapshots branch from 517ec72 to bb8376b Compare September 30, 2017 18:17
@laanwj
Copy link
Member

laanwj commented Oct 2, 2017

Yes, iterators not changing under us is an important part of our leveldb usage. I remember in the past this was well-documented. I wonder when they changed the documentation to no longer say this, and what their plans here are?

In any case it's good to check.
utACK bb8376b

@laanwj laanwj merged commit bb8376b into bitcoin:master Oct 2, 2017
laanwj added a commit that referenced this pull request Oct 2, 2017
bb8376b Verify DBWrapper iterators are taking snapshots (Matt Corallo)

Pull request description:

  The LevelDB docs seem to indicate that an iterator will not take
  snapshots (even providing instructions on how to do so yourself).
  In several of the places we use them, we assume snapshots to have
  been taken.

  In order to make sure LevelDB doesn't change out from under us
  (and to prevent the next person who reads the docs from having the
  same fright I did), verify that snapshots are taken in our tests.

Tree-SHA512: 54f24dabc294962e9c20882f61809604421a661208d1568bb107102248603e8e7c12e929ccb0812a73d4e4f23fea61f1b48e7cc24da5a7260f1d14d89ba88cd6
maflcko pushed a commit to maflcko/bitcoin-core that referenced this pull request Oct 3, 2017
The LevelDB docs seem to indicate that an iterator will not take
snapshots (even providing instructions on how to do so yourself).
In several of the places we use them, we assume snapshots to have
been taken.

In order to make sure LevelDB doesn't change out from under us
(and to prevent the next person who reads the docs from having the
same fright I did), verify that snapshots are taken in our tests.

Github-Pull: bitcoin#11422
Rebased-From: bb8376b
jasonbcox pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Aug 16, 2019
Summary:
bb8376b Verify DBWrapper iterators are taking snapshots (Matt Corallo)

Pull request description:

  The LevelDB docs seem to indicate that an iterator will not take
  snapshots (even providing instructions on how to do so yourself).
  In several of the places we use them, we assume snapshots to have
  been taken.

  In order to make sure LevelDB doesn't change out from under us
  (and to prevent the next person who reads the docs from having the
  same fright I did), verify that snapshots are taken in our tests.

Tree-SHA512: 54f24dabc294962e9c20882f61809604421a661208d1568bb107102248603e8e7c12e929ccb0812a73d4e4f23fea61f1b48e7cc24da5a7260f1d14d89ba88cd6

Backport of Core PR11422
bitcoin/bitcoin#11422

Test Plan:
  make check

Reviewers: deadalnix, Fabien, jasonbcox, O1 Bitcoin ABC, #bitcoin_abc

Reviewed By: Fabien, jasonbcox, O1 Bitcoin ABC, #bitcoin_abc

Differential Revision: https://reviews.bitcoinabc.org/D3858
codablock pushed a commit to codablock/dash that referenced this pull request Sep 24, 2019
bb8376b Verify DBWrapper iterators are taking snapshots (Matt Corallo)

Pull request description:

  The LevelDB docs seem to indicate that an iterator will not take
  snapshots (even providing instructions on how to do so yourself).
  In several of the places we use them, we assume snapshots to have
  been taken.

  In order to make sure LevelDB doesn't change out from under us
  (and to prevent the next person who reads the docs from having the
  same fright I did), verify that snapshots are taken in our tests.

Tree-SHA512: 54f24dabc294962e9c20882f61809604421a661208d1568bb107102248603e8e7c12e929ccb0812a73d4e4f23fea61f1b48e7cc24da5a7260f1d14d89ba88cd6
barrystyle pushed a commit to PACGlobalOfficial/PAC that referenced this pull request Jan 22, 2020
bb8376b Verify DBWrapper iterators are taking snapshots (Matt Corallo)

Pull request description:

  The LevelDB docs seem to indicate that an iterator will not take
  snapshots (even providing instructions on how to do so yourself).
  In several of the places we use them, we assume snapshots to have
  been taken.

  In order to make sure LevelDB doesn't change out from under us
  (and to prevent the next person who reads the docs from having the
  same fright I did), verify that snapshots are taken in our tests.

Tree-SHA512: 54f24dabc294962e9c20882f61809604421a661208d1568bb107102248603e8e7c12e929ccb0812a73d4e4f23fea61f1b48e7cc24da5a7260f1d14d89ba88cd6
random-zebra added a commit to PIVX-Project/PIVX that referenced this pull request Apr 23, 2021
bc3d3fa Add testcase to simulate bitcoin schema in leveldb (MapleLaker)
4f15155 Verify DBWrapper iterators are taking snapshots (Matt Corallo)
36b407e test: Replace remaining sprintf with snprintf (Wladimir J. van der Laan)
e8cb38a Add test for dbwrapper iterators with same-prefix keys. (Matt Corallo)
4a4ddb8 test: Add more thorough test for dbwrapper iterators I made a silly mistake in a database wrapper where keys were sorted by char instead of uint8_t. As x86 char is signed the sorting for the block index database was messed up, resulting in a segfault due to missing records. (Wladimir J. van der Laan)
109446f chain: Add assertion in case of missing records in index db (Wladimir J. van der Laan)

Pull request description:

  Back ported the following PRs from upstream (adaptations were needed because we aren't obfuscating the db):

  * bitcoin#7992.
  * bitcoin#9867.
  * bitcoin#11422.
  * bitcoin#17206

ACKs for top commit:
  random-zebra:
    Nice! ACK bc3d3fa

Tree-SHA512: ebd811d7ee0d970247ceec2624e524df7611274f36ef7c0252712ebf247828ee091dcc6872585271fac3d7846127a997a856d7cd72eb20425e06213207ff1c7a
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants