Skip to content

Commit

Permalink
Fix data race when IsReadOnly and other write operations are concurre…
Browse files Browse the repository at this point in the history
…ntly invoked

Signed-off-by: you06 <[email protected]>
  • Loading branch information
you06 committed Oct 17, 2024
1 parent c3e10ae commit 76975d6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
9 changes: 9 additions & 0 deletions internal/unionstore/memdb_art.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,15 @@ func (db *artDBWithContext) BatchGet(ctx context.Context, keys [][]byte) (map[st
return m, nil
}

// Dirty implements the MemBuffer interface.
func (db *artDBWithContext) Dirty() bool {
if !db.skipMutex {
db.RLock()
defer db.RUnlock()
}
return db.ART.Dirty()
}

// GetMetrics implements the MemBuffer interface.
func (db *artDBWithContext) GetMetrics() Metrics { return Metrics{} }

Expand Down
9 changes: 9 additions & 0 deletions internal/unionstore/memdb_rbt.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,15 @@ func (db *rbtDBWithContext) BatchGet(ctx context.Context, keys [][]byte) (map[st
return m, nil
}

// Dirty implements the MemBuffer interface.
func (db *rbtDBWithContext) Dirty() bool {
if !db.skipMutex {
db.RLock()
defer db.RUnlock()
}
return db.RBT.Dirty()
}

// GetMetrics implements the MemBuffer interface.
func (db *rbtDBWithContext) GetMetrics() Metrics { return Metrics{} }

Expand Down

0 comments on commit 76975d6

Please sign in to comment.