Skip to content

Conversation

@achow101
Copy link
Member

@achow101 achow101 commented Oct 6, 2020

We never have multiple threads making able to multiple WalletBatchs due to the extensive use of cs_wallet, cs_KeyStore, and cs_desc_man, so the use of refcounting to handle the case where that may happen is unnecessary. Thus we can use an assert to enforce that only one BerkeleyBatch is accessing the BerkeleyDatabase at a time. The only instances where multiple BerkeleyBatchs were being created were where one was made in a caller function, and then the called function created another for itself. For those cases, we instead either pass in the caller's WalletBatch or limit the scope of the caller's WalletBatch so that there are no overlaps.

The refcounting in BerkeleyDatabase is kept because it did more than just count the number of BerkeleyBatchs, it also indicated when the database was flushed. However the AddRef and RemoveRef functions have been removed from WalletDatabase.

@fanquake fanquake added the Wallet label Oct 6, 2020
@DrahtBot
Copy link
Contributor

DrahtBot commented Oct 7, 2020

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #23414 (wallet: Fix comment grammar in bdb.h by zealsham)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

Copy link
Member

Choose a reason for hiding this comment

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

this is failing for me:
AssertionError: Unexpected stderr Assertion failed: (m_refcount <= 1), function AddRef, file wallet/bdb.cpp, line 794. !=

Copy link
Contributor

@promag promag left a comment

Choose a reason for hiding this comment

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

Concept ACK, Improves/simplifies the codebase by dropping useless support for concurrent batches.

Do you want to rebase to get a fresh CI?

@maflcko
Copy link
Member

maflcko commented Oct 19, 2021

It failed with

�[0;32m node1 stderr bitcoind: wallet/bdb.cpp:811: void BerkeleyDatabase::AddRef(): Assertion `m_refcount <= 1' failed. �[0m

So I don't think this is a CI issues that can be fixed by a rebase

@promag
Copy link
Contributor

promag commented Oct 19, 2021

Ok, fix and rebase 🙉

@DrahtBot
Copy link
Contributor

DrahtBot commented Nov 9, 2021

🐙 This pull request conflicts with the target branch and needs rebase.

Want to unsubscribe from rebase notifications on this pull request? Just convert this pull request to a "draft".

@achow101
Copy link
Member Author

achow101 commented Nov 9, 2021

Closing as the constraint is no longer true due to nesting.

@achow101 achow101 closed this Nov 9, 2021
@bitcoin bitcoin locked and limited conversation to collaborators Nov 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants