File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed
Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -65,6 +65,11 @@ func (t *shared) Free(txid common.Txid, p *common.Page) {
6565 t .pending [txid ] = txp
6666 }
6767 allocTxid , ok := t .allocs [p .Id ()]
68+ common .Verify (func () {
69+ if allocTxid == txid {
70+ panic (fmt .Sprintf ("free: freed page (%d) was allocated by the same transaction (%d)" , p .Id (), txid ))
71+ }
72+ })
6873 if ok {
6974 delete (t .allocs , p .Id ())
7075 }
@@ -87,7 +92,6 @@ func (t *shared) Rollback(txid common.Txid) {
8792 if txp == nil {
8893 return
8994 }
90- var m common.Pgids
9195 for i , pgid := range txp .ids {
9296 delete (t .cache , pgid )
9397 tx := txp .alloctx [i ]
@@ -98,13 +102,12 @@ func (t *shared) Rollback(txid common.Txid) {
98102 // Pending free aborted; restore page back to alloc list.
99103 t .allocs [pgid ] = tx
100104 } else {
101- // Freed page was allocated by this txn; OK to throw away .
102- m = append ( m , pgid )
105+ // A writing TXN should never free a page which was allocated by itself .
106+ panic ( fmt . Sprintf ( "rollback: freed page (%d) was allocated by the same transaction (%d)" , pgid , txid ) )
103107 }
104108 }
105109 // Remove pages from pending list and mark as free if allocated by txid.
106110 delete (t .pending , txid )
107- t .mergeSpans (m )
108111}
109112
110113func (t * shared ) AddReadonlyTXID (tid common.Txid ) {
You can’t perform that action at this time.
0 commit comments