Skip to content

Commit

Permalink
Remove list.SetForDeletion method, remnant of the global LRU cache. (#…
Browse files Browse the repository at this point in the history
…3481)

Also remove a defer func which was calculating pendingTxns.
  • Loading branch information
manishrjain authored May 30, 2019
1 parent 4748b65 commit bb8b3b5
Showing 1 changed file with 0 additions and 32 deletions.
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

0 comments on commit bb8b3b5

Please sign in to comment.