22
33use std:: collections:: HashMap ;
44use std:: sync:: Arc ;
5- use std:: time:: Instant ;
65
76use indexmap:: IndexMap ;
87use 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
2724impl 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