Skip to content

Commit a1c9240

Browse files
committed
refactor: eliminate unnecessary tx props
Neither AbortHandle nor created_at were actually used/useful
1 parent 99c5b81 commit a1c9240

2 files changed

Lines changed: 5 additions & 23 deletions

File tree

src/commands.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -349,12 +349,8 @@ pub async fn execute_interruptible_transaction(
349349
q.execute(&mut *writer).await?;
350350
}
351351

352-
// Create abort handle for transaction cleanup on app exit
353-
let abort_handle = tokio::spawn(std::future::pending::<()>()).abort_handle();
354-
355352
// Store transaction state
356-
let tx =
357-
ActiveInterruptibleTransaction::new(db.clone(), transaction_id.clone(), writer, abort_handle);
353+
let tx = ActiveInterruptibleTransaction::new(db.clone(), transaction_id.clone(), writer);
358354

359355
active_txs.insert(db.clone(), tx).await?;
360356

src/transactions.rs

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
33
use std::collections::HashMap;
44
use std::sync::Arc;
5-
use std::time::Instant;
65

76
use indexmap::IndexMap;
87
use serde::Deserialize;
@@ -20,23 +19,14 @@ pub struct ActiveInterruptibleTransaction {
2019
db_path: String,
2120
transaction_id: String,
2221
writer: WriteGuard,
23-
abort_handle: AbortHandle,
24-
created_at: Instant,
2522
}
2623

2724
impl ActiveInterruptibleTransaction {
28-
pub fn new(
29-
db_path: String,
30-
transaction_id: String,
31-
writer: WriteGuard,
32-
abort_handle: AbortHandle,
33-
) -> Self {
25+
pub fn new(db_path: String, transaction_id: String, writer: WriteGuard) -> Self {
3426
Self {
3527
db_path,
3628
transaction_id,
3729
writer,
38-
abort_handle,
39-
created_at: Instant::now(),
4030
}
4131
}
4232

@@ -48,10 +38,6 @@ impl ActiveInterruptibleTransaction {
4838
&self.transaction_id
4939
}
5040

51-
pub fn created_at(&self) -> Instant {
52-
self.created_at
53-
}
54-
5541
pub fn validate_token(&self, token_id: &str) -> Result<()> {
5642
if self.transaction_id != token_id {
5743
return Err(Error::InvalidTransactionToken);
@@ -157,15 +143,15 @@ impl ActiveInterruptibleTransactions {
157143
let mut txs = self.0.write().await;
158144
debug!("Aborting {} active interruptible transaction(s)", txs.len());
159145

160-
for (db_path, tx) in txs.iter() {
146+
for db_path in txs.keys() {
161147
debug!(
162-
"Aborting interruptible transaction for database: {}",
148+
"Dropping interruptible transaction for database: {}",
163149
db_path
164150
);
165-
tx.abort_handle.abort();
166151
}
167152

168153
// Clear all transactions to drop WriteGuards and release locks
154+
// Dropping triggers auto-rollback via Drop trait
169155
txs.clear();
170156
}
171157

0 commit comments

Comments
 (0)