Skip to content

Use ReadTransactions in TxnManager message listener #6807

@emhane

Description

@emhane

Describe the feature

ReadTransactions should be cloned into the TxnManager::start_message_listener.

#[cfg(feature = "read-tx-timeouts")]
let read_transactions = self.read_transactions.clone();

Currently it's not unless ReadTransactions is set before calling TxnManager::start_message_listener since it is wrapped in Option<Arc<_>>, not in Arc<Option<_>>.

#[cfg(feature = "read-tx-timeouts")]
read_transactions: Option<std::sync::Arc<read_transactions::ReadTransactions>>,

This is not the case, ReadTransactions is set after calling TxnManager::start_message_listener.

let mut txn_manager = TxnManager::new(EnvPtr(env));
if let crate::MaxReadTransactionDuration::Set(duration) = self
.max_read_transaction_duration
.unwrap_or(read_transactions::MaxReadTransactionDuration::Set(
DEFAULT_MAX_READ_TRANSACTION_DURATION,
))
{
txn_manager = txn_manager.with_max_read_transaction_duration(duration);

pub(crate) fn new(env: EnvPtr) -> Self {
let (tx, rx) = sync_channel(0);
let txn_manager = Self {
sender: tx,
#[cfg(feature = "read-tx-timeouts")]
read_transactions: None,
};
txn_manager.start_message_listener(env, rx);
txn_manager
}

(https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=b44d4a8d43eb2d30f52a06a640cde715)

Additional context

No response

Metadata

Metadata

Assignees

Labels

A-dbRelated to the databaseC-bugAn unexpected or incorrect behavior

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions