Skip to content

Commit 87458c9

Browse files
committed
Protect meta page when it's being written
Signed-off-by: Benjamin Wang <[email protected]>
1 parent 014567e commit 87458c9

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
@@ -509,9 +509,12 @@ func (tx *Tx) writeMeta() error {
509509
tx.meta.write(p)
510510

511511
// Write the meta page to file.
512+
tx.db.metalock.Lock()
512513
if _, err := tx.db.ops.writeAt(buf, int64(p.id)*int64(tx.db.pageSize)); err != nil {
514+
tx.db.metalock.Unlock()
513515
return err
514516
}
517+
tx.db.metalock.Unlock()
515518
if !tx.db.NoSync || IgnoreNoSync {
516519
// gofail: var beforeSyncMetaPage struct{}
517520
if err := fdatasync(tx.db); err != nil {

0 commit comments

Comments
 (0)