Fix a data race in Datafile.ReadAt()

This commit is contained in:
James Mills 2021-11-01 17:54:31 +10:00
parent f4cc0fb434
commit 40425394d7
No known key found for this signature in database
GPG Key ID: AC4C014F1440EBD6

@ -6,9 +6,9 @@ import (
"path/filepath"
"sync"
"github.com/pkg/errors"
"git.mills.io/prologic/bitcask/internal"
"git.mills.io/prologic/bitcask/internal/data/codec"
"github.com/pkg/errors"
"golang.org/x/exp/mmap"
)
@ -159,6 +159,9 @@ func (df *datafile) ReadAt(index, size int64) (e internal.Entry, err error) {
b := make([]byte, size)
df.RLock()
defer df.RUnlock()
if df.ra != nil {
n, err = df.ra.ReadAt(b, index)
} else {