File tree 1 file changed +7
-4
lines changed
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) {
65
65
t .pending [txid ] = txp
66
66
}
67
67
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
+ })
68
73
if ok {
69
74
delete (t .allocs , p .Id ())
70
75
}
@@ -87,7 +92,6 @@ func (t *shared) Rollback(txid common.Txid) {
87
92
if txp == nil {
88
93
return
89
94
}
90
- var m common.Pgids
91
95
for i , pgid := range txp .ids {
92
96
delete (t .cache , pgid )
93
97
tx := txp .alloctx [i ]
@@ -98,13 +102,12 @@ func (t *shared) Rollback(txid common.Txid) {
98
102
// Pending free aborted; restore page back to alloc list.
99
103
t .allocs [pgid ] = tx
100
104
} 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 ) )
103
107
}
104
108
}
105
109
// Remove pages from pending list and mark as free if allocated by txid.
106
110
delete (t .pending , txid )
107
- t .mergeSpans (m )
108
111
}
109
112
110
113
func (t * shared ) AddReadonlyTXID (tid common.Txid ) {
You can’t perform that action at this time.
0 commit comments