Skip to content

Commit 3e3e01a

Browse files
corylanouclaude
andcommitted
fix: remove leftover merge conflict marker
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 3428aad commit 3e3e01a

File tree

2 files changed

+14
-52
lines changed

2 files changed

+14
-52
lines changed

cmd/litestream-vfs/main_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,6 @@ done:
510510
if finalValue == initialValue {
511511
t.Fatalf("expected updated value after commit")
512512
}
513-
>>>>>>> 95c60ce (test(vfs): add comprehensive integration and unit tests)
514513
}
515514

516515
func TestVFS_HighLoadConcurrentReads(t *testing.T) {

vfs.go

Lines changed: 14 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,6 @@ const (
3030
pageFetchRetryDelay = 15 * time.Millisecond
3131
)
3232

33-
// VFSReadInterceptor observes page read attempts. Returning a non-nil error
34-
// causes the read to fail. Primarily intended for instrumentation and testing.
35-
type VFSReadInterceptor interface {
36-
BeforePageRead(name string, off int64, n int) error
37-
}
38-
39-
// VFSReadInterceptorFunc adapts a function to the VFSReadInterceptor interface.
40-
type VFSReadInterceptorFunc func(name string, off int64, n int) error
41-
42-
// BeforePageRead invokes fn if it is non-nil.
43-
func (fn VFSReadInterceptorFunc) BeforePageRead(name string, off int64, n int) error {
44-
if fn == nil {
45-
return nil
46-
}
47-
return fn(name, off, n)
48-
}
49-
5033
type vfsContextKey string
5134

5235
const pageFetchContextKey vfsContextKey = "litestream/vfs/page-fetch"
@@ -88,8 +71,6 @@ type VFS struct {
8871
tempDir string
8972
tempDirErr error
9073
tempFiles sync.Map // canonical name -> absolute path
91-
92-
readInterceptor VFSReadInterceptor
9374
}
9475

9576
func NewVFS(client ReplicaClient, logger *slog.Logger) *VFS {
@@ -102,10 +83,6 @@ func NewVFS(client ReplicaClient, logger *slog.Logger) *VFS {
10283
}
10384

10485
// SetReadInterceptor installs interceptor for page reads issued through this VFS.
105-
func (vfs *VFS) SetReadInterceptor(interceptor VFSReadInterceptor) {
106-
vfs.readInterceptor = interceptor
107-
}
108-
10986
func (vfs *VFS) Open(name string, flags sqlite3vfs.OpenFlag) (sqlite3vfs.File, sqlite3vfs.OpenFlag, error) {
11087
slog.Info("opening file", "name", name, "flags", flags)
11188

@@ -123,7 +100,6 @@ func (vfs *VFS) openMainDB(name string, flags sqlite3vfs.OpenFlag) (sqlite3vfs.F
123100
f := NewVFSFile(vfs.client, name, vfs.logger.With("name", name))
124101
f.PollInterval = vfs.PollInterval
125102
f.CacheSize = vfs.CacheSize
126-
f.SetReadInterceptor(vfs.readInterceptor)
127103
if err := f.Open(); err != nil {
128104
return nil, 0, err
129105
}
@@ -380,16 +356,15 @@ type VFSFile struct {
380356
client ReplicaClient
381357
name string
382358

383-
pos ltx.Pos // Last TXID read from level 0 or 1
384-
maxTXID1 ltx.TXID // Last TXID read from level 1
385-
index map[uint32]ltx.PageIndexElem
386-
pending map[uint32]ltx.PageIndexElem
387-
pendingReplace bool
388-
cache *lru.Cache[uint32, []byte] // LRU cache for page data
389-
lockType sqlite3vfs.LockType // Current lock state
390-
pageSize uint32
391-
commit uint32
392-
readInterceptor VFSReadInterceptor
359+
pos ltx.Pos // Last TXID read from level 0 or 1
360+
maxTXID1 ltx.TXID // Last TXID read from level 1
361+
index map[uint32]ltx.PageIndexElem
362+
pending map[uint32]ltx.PageIndexElem
363+
pendingReplace bool
364+
cache *lru.Cache[uint32, []byte] // LRU cache for page data
365+
lockType sqlite3vfs.LockType // Current lock state
366+
pageSize uint32
367+
commit uint32
393368

394369
wg sync.WaitGroup
395370
ctx context.Context
@@ -415,11 +390,6 @@ func NewVFSFile(client ReplicaClient, name string, logger *slog.Logger) *VFSFile
415390
return f
416391
}
417392

418-
// SetReadInterceptor installs a read interceptor for the file.
419-
func (f *VFSFile) SetReadInterceptor(interceptor VFSReadInterceptor) {
420-
f.readInterceptor = interceptor
421-
}
422-
423393
// Pos returns the current position of the file.
424394
func (f *VFSFile) Pos() ltx.Pos {
425395
f.mu.Lock()
@@ -534,10 +504,6 @@ func (f *VFSFile) ReadAt(p []byte, off int64) (n int, err error) {
534504
return 0, err
535505
}
536506

537-
if err := f.beforePageRead(off, len(p)); err != nil {
538-
return 0, err
539-
}
540-
541507
pgno := uint32(off/int64(pageSize)) + 1
542508

543509
// Check cache first (cache is thread-safe)
@@ -810,26 +776,30 @@ func (f *VFSFile) pollReplicaClient(ctx context.Context) error {
810776
// Apply updates and invalidate cache entries for updated pages
811777
invalidateN := 0
812778
target := f.index
779+
targetIsMain := true
813780
if f.lockType >= sqlite3vfs.LockShared {
814781
target = f.pending
782+
targetIsMain = false
815783
} else {
816784
f.pendingReplace = false
817785
}
818786
if replaceIndex {
819787
if f.lockType < sqlite3vfs.LockShared {
820788
f.index = make(map[uint32]ltx.PageIndexElem)
821789
target = f.index
790+
targetIsMain = true
822791
f.pendingReplace = false
823792
} else {
824793
f.pending = make(map[uint32]ltx.PageIndexElem)
825794
target = f.pending
795+
targetIsMain = false
826796
f.pendingReplace = true
827797
}
828798
}
829799
for k, v := range combined {
830800
target[k] = v
831801
// Invalidate cache if we're updating the main index
832-
if target == f.index {
802+
if targetIsMain {
833803
f.cache.Remove(k)
834804
invalidateN++
835805
}
@@ -924,13 +894,6 @@ func (f *VFSFile) pageSizeBytes() (uint32, error) {
924894
return pageSize, nil
925895
}
926896

927-
func (f *VFSFile) beforePageRead(off int64, n int) error {
928-
if f.readInterceptor == nil {
929-
return nil
930-
}
931-
return f.readInterceptor.BeforePageRead(f.name, off, n)
932-
}
933-
934897
func detectPageSizeFromInfos(ctx context.Context, client ReplicaClient, infos []*ltx.FileInfo) (uint32, error) {
935898
var lastErr error
936899
for i := len(infos) - 1; i >= 0; i-- {

0 commit comments

Comments
 (0)