Skip to content

[Bug]: concurrency conflict in MemPool.TryRemoveUnVerified #3499

@nan01ab

Description

@nan01ab

Describe the bug

There two write operations in MemPool.TryRemoveUnVerified, and this function called by Blockchain.OnFillMemoryPool and MemPool.UpdatePoolForBlockPersisted.

Write operations triggered by MemPool.UpdatePoolForBlockPersisted is protected by _txRwLock, but by Blockchain.OnFillMemoryPool is not.

        internal bool TryRemoveUnVerified(UInt256 hash, [MaybeNullWhen(false)] out PoolItem? item)
        {
            if (!_unverifiedTransactions.TryGetValue(hash, out item))
                return false;

            _unverifiedTransactions.Remove(hash);
            _unverifiedSortedTransactions.Remove(item);
            return true;
        }

According to comments of _txRwLock, write operations should acquire write lock of _txRwLock.

Metadata

Metadata

Assignees

Labels

SuggestionIdeas and suggestions that could be used for improving clarity, organization or even performance.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions