Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove list.SetForDeletion method, remnant of the global LRU cache. #3481

Merged
merged 2 commits into from
May 30, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 0 additions & 32 deletions posting/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"log"
"math"
"sort"
"sync/atomic"

"github.com/dgryski/go-farm"
"github.com/golang/glog"
Expand Down Expand Up @@ -73,9 +72,6 @@ type List struct {
mutationMap map[uint64]*pb.PostingList
minTs uint64 // commit timestamp of immutable layer, reject reads before this ts.
maxTs uint64 // max commit timestamp seen for this list.

pendingTxns int32 // Using atomic for this, to avoid locking in SetForDeletion operation.
deleteMe int32 // Using atomic for this, to avoid expensive SetForDeletion operation.
}

func (l *List) maxVersion() uint64 {
Expand Down Expand Up @@ -292,17 +288,6 @@ func NewPosting(t *pb.DirectedEdge) *pb.Posting {
}
}

// SetForDeletion will mark this List to be deleted, so no more mutations can be applied to this.
// Ensure that we don't acquire any locks during a call to this function, so the LRU cache can
// proceed smoothly.
func (l *List) SetForDeletion() bool {
if atomic.LoadInt32(&l.pendingTxns) > 0 {
return false
}
atomic.StoreInt32(&l.deleteMe, 1)
return true
}

func hasDeleteAll(mpost *pb.Posting) bool {
return mpost.Op == Del && bytes.Equal(mpost.Value, []byte(x.Star)) && len(mpost.LangTag) == 0
}
Expand Down Expand Up @@ -409,9 +394,6 @@ func (l *List) canMutateUid(txn *Txn, edge *pb.DirectedEdge) error {
}

func (l *List) addMutation(ctx context.Context, txn *Txn, t *pb.DirectedEdge) error {
if atomic.LoadInt32(&l.deleteMe) == 1 {
return ErrRetry
}
if txn.ShouldAbort() {
return y.ErrConflict
}
Expand Down Expand Up @@ -458,7 +440,6 @@ func (l *List) addMutation(ctx context.Context, txn *Txn, t *pb.DirectedEdge) er
}

l.updateMutationLayer(mpost)
atomic.AddInt32(&l.pendingTxns, 1)
txn.AddConflictKey(conflictKey)
return nil
}
Expand Down Expand Up @@ -491,21 +472,8 @@ func (l *List) CommitMutation(startTs, commitTs uint64) error {
}

func (l *List) commitMutation(startTs, commitTs uint64) error {
if atomic.LoadInt32(&l.deleteMe) == 1 {
return ErrRetry
}
l.AssertLock()

// Check if we still have a pending txn when we return from this function.
defer func() {
for _, plist := range l.mutationMap {
if plist.CommitTs == 0 {
return // Got a pending txn.
}
}
atomic.StoreInt32(&l.pendingTxns, 0)
}()

plist, ok := l.mutationMap[startTs]
if !ok {
// It was already committed, might be happening due to replay.
Expand Down