code: func (s *Store) kvsUnlockTxn(tx *memdb.Txn, idx uint64, entry *structs.DirEntry) (bool, error) {
  	// Verify that a session is present.
  	if entry.Session == "" {
  		return false, fmt.Errorf("missing session")
  	}
  
  	// Retrieve the existing entry.
  	existing, err := tx.First("kvs", "id", entry.Key)
  	if err != nil {
  		return false, fmt.Errorf("failed kvs lookup: %s", err)
  	}
  
  	// Bail if there's no existing key.
  	if existing == nil {
  		return false, nil
  	}
  
  	// Make sure the given session is the lock holder.
  	e := existing.(*structs.DirEntry)
  	if e.Session != entry.Session {
  		return false, nil
  	}
  
  	// Clear the lock and update the entry.
  	entry.Session = ""
  	entry.LockIndex = e.LockIndex
  	entry.CreateIndex = e.CreateIndex
  	entry.ModifyIndex = idx
  
  	// If we made it this far, we should perform the set.
  	if err := s.kvsSetTxn(tx, idx, entry, true); err != nil {
  		return false, err
  	}
  	return true, nil
  }
docs: // kvsUnlockTxn is the inner method that does an unlock inside an existing
  // transaction.