Skip to content

Commit d378a05

Browse files
authored
Merge pull request #973 from nspcc-dev/drop-unused-txs-main
db: drop unused txs list
2 parents 3e91289 + d18aaf8 commit d378a05

File tree

1 file changed

+2
-17
lines changed

1 file changed

+2
-17
lines changed

db.go

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ type DB struct {
138138
pageSize int
139139
opened bool
140140
rwtx *Tx
141-
txs []*Tx
142141

143142
freelist fl.Interface
144143
freelistLoad sync.Once
@@ -801,9 +800,6 @@ func (db *DB) beginTx() (*Tx, error) {
801800
t := &Tx{}
802801
t.init(db)
803802

804-
// Keep track of transaction until it closes.
805-
db.txs = append(db.txs, t)
806-
n := len(db.txs)
807803
if db.freelist != nil {
808804
db.freelist.AddReadonlyTXID(t.meta.Txid())
809805
}
@@ -814,7 +810,7 @@ func (db *DB) beginTx() (*Tx, error) {
814810
// Update the transaction stats.
815811
db.statlock.Lock()
816812
db.stats.TxN++
817-
db.stats.OpenTxN = n
813+
db.stats.OpenTxN++
818814
db.statlock.Unlock()
819815

820816
return t, nil
@@ -863,17 +859,6 @@ func (db *DB) removeTx(tx *Tx) {
863859
// Use the meta lock to restrict access to the DB object.
864860
db.metalock.Lock()
865861

866-
// Remove the transaction.
867-
for i, t := range db.txs {
868-
if t == tx {
869-
last := len(db.txs) - 1
870-
db.txs[i] = db.txs[last]
871-
db.txs[last] = nil
872-
db.txs = db.txs[:last]
873-
break
874-
}
875-
}
876-
n := len(db.txs)
877862
if db.freelist != nil {
878863
db.freelist.RemoveReadonlyTXID(tx.meta.Txid())
879864
}
@@ -883,7 +868,7 @@ func (db *DB) removeTx(tx *Tx) {
883868

884869
// Merge statistics.
885870
db.statlock.Lock()
886-
db.stats.OpenTxN = n
871+
db.stats.OpenTxN--
887872
db.stats.TxStats.add(&tx.stats)
888873
db.statlock.Unlock()
889874
}

0 commit comments

Comments
 (0)