Exemplo n.º 1
0
// Iterate walks through the abort cache, invoking the given callback for
// each unmarshaled entry with the key, the transaction ID and the decoded
// entry.
// TODO(tschottdorf): should not use a pointer to UUID.
func (sc *AbortCache) Iterate(
	ctx context.Context, e engine.Reader, f func([]byte, roachpb.AbortCacheEntry),
) {
	_, _ = engine.MVCCIterate(ctx, e, sc.min(), sc.max(), hlc.ZeroTimestamp,
		true /* consistent */, nil /* txn */, false, /* !reverse */
		func(kv roachpb.KeyValue) (bool, error) {
			var entry roachpb.AbortCacheEntry
			if _, err := keys.DecodeAbortCacheKey(kv.Key, nil); err != nil {
				panic(err) // TODO(tschottdorf): ReplicaCorruptionError
			}
			if err := kv.Value.GetProto(&entry); err != nil {
				panic(err) // TODO(tschottdorf): ReplicaCorruptionError
			}
			f(kv.Key, entry)
			return false, nil
		})
}
Exemplo n.º 2
0
func decodeAbortCacheMVCCKey(encKey engine.MVCCKey, dest []byte) (uuid.UUID, error) {
	if encKey.IsValue() {
		return uuid.UUID{}, errors.Errorf("key %s is not a raw MVCC value", encKey)
	}
	return keys.DecodeAbortCacheKey(encKey.Key, dest)
}