Gotomic PL has empty key?

Go to lists.go.

Go to GetOrCreate. Look for the following code:

if lp != nil {
  return lp.(*List)
}

Essentially, it is looking up the gotomic hash for a cached copy of a List object (or PL or posting list).

Now modify it to the following

if lp != nil {
  tmp := lp.(*List)
  if len(tmp.key) == 0 {
    log.Fatalf("~~~~~~~~[%s] [%s]", string(key), tmp.key)
  }
  return tmp
}

Do you see any errors when you run loader? I see things like

2016/09/08 09:21:07 lists.go:281: ~~~~~~~~[film.film.starring|�e�H5��] []

Is it possible that before list.key got updated later on in list.init, somebody already tried to grab that PL from gotomic hash? Do we need to acquire a lock on tmp or leave it to downstream users to be careful? Or add to lhmap only after l.init returns.

Proposed solution:

	l := NewList()
	l.init(key, pstore, clog)
	if lhmap.PutIfMissing(ukey, l) {
		return l
	}
	lp, _ = lhmap.Get(ukey)
	return lp.(*List)

This is not a bug as we discussed. The struct uses locks before any internal fields are accessed, but because you’re in the same package, you’re able to access the internal field. You should acquire proper locks before using internal fields.

// AddMutationWithIndex is AddMutation with support for indexing.
func (l *List) AddMutationWithIndex(ctx context.Context, t x.DirectedEdge, op byte) error {
	l.RLock()
	x.Assert(len(l.key) > 0 && l.key[0] != indexByte)
	doUpdateIndex := t.Value != nil && indexedAttr[l.keyAttr]
	l.RUnlock()

The above is still failing. We might have made it here before List.init() acquires a write lock.

You’re missing this:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.