Skip to content

Commit 68b0ba4

Browse files
authored
Merge pull request #989 from nspcc-dev/metalock
tx: add missing lock on meta page update
2 parents be68cc2 + 249746f commit 68b0ba4

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

tx.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,10 +563,13 @@ func (tx *Tx) writeMeta() error {
563563
tx.meta.Write(p)
564564

565565
// Write the meta page to file.
566+
tx.db.metalock.Lock()
566567
if _, err := tx.db.ops.writeAt(buf, int64(p.Id())*int64(tx.db.pageSize)); err != nil {
568+
tx.db.metalock.Unlock()
567569
lg.Errorf("writeAt failed, pgid: %d, pageSize: %d, error: %v", p.Id(), tx.db.pageSize, err)
568570
return err
569571
}
572+
tx.db.metalock.Unlock()
570573
if !tx.db.NoSync || common.IgnoreNoSync {
571574
// gofail: var beforeSyncMetaPage struct{}
572575
if err := fdatasync(tx.db); err != nil {

0 commit comments

Comments
 (0)