本文整理汇总了Golang中github.com/cockroachdb/cockroach/storage/engine.MakeMVCCMetadataKey函数的典型用法代码示例。如果您正苦于以下问题:Golang MakeMVCCMetadataKey函数的具体用法?Golang MakeMVCCMetadataKey怎么用?Golang MakeMVCCMetadataKey使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MakeMVCCMetadataKey函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: runDebugRaftLog
func runDebugRaftLog(cmd *cobra.Command, args []string) error {
stopper := stop.NewStopper()
defer stopper.Stop()
if len(args) != 2 {
return errors.New("required arguments: dir range_id")
}
db, err := openStore(cmd, args[0], stopper)
if err != nil {
return err
}
rangeID, err := parseRangeID(args[1])
if err != nil {
return err
}
start := engine.MakeMVCCMetadataKey(keys.RaftLogPrefix(rangeID))
end := engine.MakeMVCCMetadataKey(keys.RaftLogPrefix(rangeID).PrefixEnd())
if err := db.Iterate(start, end, printRaftLogEntry); err != nil {
return err
}
return nil
}
开发者ID:csdigi,项目名称:cockroach,代码行数:26,代码来源:debug.go
示例2: loadRangeDescriptor
func loadRangeDescriptor(
db engine.Engine, rangeID roachpb.RangeID,
) (roachpb.RangeDescriptor, error) {
var desc roachpb.RangeDescriptor
handleKV := func(kv engine.MVCCKeyValue) (bool, error) {
if kv.Key.Timestamp == hlc.ZeroTimestamp {
// We only want values, not MVCCMetadata.
return false, nil
}
if err := checkRangeDescriptorKey(kv.Key); err != nil {
// Range descriptor keys are interleaved with others, so if it
// doesn't parse as a range descriptor just skip it.
return false, nil
}
if err := getProtoValue(kv.Value, &desc); err != nil {
return false, err
}
return desc.RangeID == rangeID, nil
}
// Range descriptors are stored by key, so we have to scan over the
// range-local data to find the one for this RangeID.
start := engine.MakeMVCCMetadataKey(keys.LocalRangePrefix)
end := engine.MakeMVCCMetadataKey(keys.LocalRangeMax)
if err := db.Iterate(start, end, handleKV); err != nil {
return roachpb.RangeDescriptor{}, err
}
if desc.RangeID == rangeID {
return desc, nil
}
return roachpb.RangeDescriptor{}, fmt.Errorf("range descriptor %d not found", rangeID)
}
开发者ID:YuleiXiao,项目名称:cockroach,代码行数:33,代码来源:debug.go
示例3: CopyFrom
// CopyFrom copies all the persisted results from the originRangeID
// sequence cache into this one. Note that the cache will not be
// locked while copying is in progress. Failures decoding individual
// entries return an error. The copy is done directly using the engine
// instead of interpreting values through MVCC for efficiency.
func (sc *SequenceCache) CopyFrom(e engine.Engine, originRangeID roachpb.RangeID) error {
originMin := engine.MakeMVCCMetadataKey(
keys.SequenceCacheKey(originRangeID, txnIDMin, math.MaxUint32, math.MaxUint32))
originMax := engine.MakeMVCCMetadataKey(
keys.SequenceCacheKey(originRangeID, txnIDMax, 0, 0))
return copySeqCache(e, originRangeID, sc.rangeID, originMin, originMax)
}
开发者ID:billhongs,项目名称:cockroach,代码行数:12,代码来源:sequence_cache.go
示例4: CopyInto
// CopyInto copies all the results from this abort cache into the destRangeID
// abort cache. Failures decoding individual cache entries return an error.
// On success, returns the number of entries (key-value pairs) copied.
func (sc *AbortCache) CopyInto(
e engine.Engine,
ms *engine.MVCCStats,
destRangeID roachpb.RangeID,
) (int, error) {
return copySeqCache(e, ms, sc.rangeID, destRangeID,
engine.MakeMVCCMetadataKey(sc.min()), engine.MakeMVCCMetadataKey(sc.max()))
}
开发者ID:GitGoldie,项目名称:cockroach,代码行数:11,代码来源:abort_cache.go
示例5: ClearData
// ClearData removes all persisted items stored in the cache.
func (sc *AbortCache) ClearData(e engine.Engine) error {
b := e.NewBatch()
defer b.Close()
_, err := engine.ClearRange(b, engine.MakeMVCCMetadataKey(sc.min()), engine.MakeMVCCMetadataKey(sc.max()))
if err != nil {
return err
}
return b.Commit()
}
开发者ID:mjibson,项目名称:cockroach,代码行数:10,代码来源:abort_cache.go
示例6: CopyFrom
// CopyFrom copies all the persisted results from the originRangeID
// abort cache into this one. Note that the cache will not be
// locked while copying is in progress. Failures decoding individual
// entries return an error. The copy is done directly using the engine
// instead of interpreting values through MVCC for efficiency.
// On success, returns the number of entries (key-value pairs) copied.
func (sc *AbortCache) CopyFrom(
ctx context.Context,
e engine.Engine,
ms *engine.MVCCStats,
originRangeID roachpb.RangeID,
) (int, error) {
originMin := engine.MakeMVCCMetadataKey(keys.AbortCacheKey(originRangeID, txnIDMin))
originMax := engine.MakeMVCCMetadataKey(keys.AbortCacheKey(originRangeID, txnIDMax))
return copySeqCache(e, ms, originRangeID, sc.rangeID, originMin, originMax)
}
开发者ID:GitGoldie,项目名称:cockroach,代码行数:16,代码来源:abort_cache.go
示例7: runDebugKeys
func runDebugKeys(cmd *cobra.Command, args []string) error {
stopper := stop.NewStopper()
defer stopper.Stop()
if len(args) != 1 {
return errors.New("one argument is required")
}
db, err := openStore(cmd, args[0], stopper)
if err != nil {
return err
}
d := cliContext.debug
from := engine.NilKey
to := engine.MVCCKeyMax
if d.raw {
if len(d.startKey) > 0 {
from = engine.MakeMVCCMetadataKey(roachpb.Key(d.startKey))
}
if len(d.endKey) > 0 {
to = engine.MakeMVCCMetadataKey(roachpb.Key(d.endKey))
}
} else {
if len(d.startKey) > 0 {
startKey, err := keys.UglyPrint(d.startKey)
if err != nil {
return err
}
from = engine.MakeMVCCMetadataKey(startKey)
}
if len(d.endKey) > 0 {
endKey, err := keys.UglyPrint(d.endKey)
if err != nil {
return err
}
to = engine.MakeMVCCMetadataKey(endKey)
}
}
printer := printKey
if d.values {
printer = printKeyValue
}
if err := db.Iterate(from, to, printer); err != nil {
return err
}
return nil
}
开发者ID:nieyy,项目名称:cockroach,代码行数:52,代码来源:debug.go
示例8: copySeqCache
func copySeqCache(e engine.Engine, srcID, dstID roachpb.RangeID, keyMin, keyMax engine.MVCCKey) error {
var scratch [64]byte
return e.Iterate(keyMin, keyMax,
func(kv engine.MVCCKeyValue) (bool, error) {
// Decode the key into a cmd, skipping on error. Otherwise,
// write it to the corresponding key in the new cache.
id, epoch, seq, err := decodeSequenceCacheMVCCKey(kv.Key, scratch[:0])
if err != nil {
return false, util.Errorf("could not decode a sequence cache key %s: %s",
kv.Key, err)
}
key := keys.SequenceCacheKey(dstID, id, epoch, seq)
encKey := engine.MakeMVCCMetadataKey(key)
// Decode the value, update the checksum and re-encode.
meta := &engine.MVCCMetadata{}
if err := proto.Unmarshal(kv.Value, meta); err != nil {
return false, util.Errorf("could not decode sequence cache value %s [% x]: %s",
kv.Key, kv.Value, err)
}
value := meta.Value()
value.ClearChecksum()
value.InitChecksum(key)
meta.RawBytes = value.RawBytes
_, _, err = engine.PutProto(e, encKey, meta)
return false, err
})
}
开发者ID:billhongs,项目名称:cockroach,代码行数:27,代码来源:sequence_cache.go
示例9: runDebugRangeDescriptors
func runDebugRangeDescriptors(cmd *cobra.Command, args []string) error {
stopper := stop.NewStopper()
defer stopper.Stop()
db, err := openStore(cmd, args, stopper)
if err != nil {
return err
}
start := engine.MakeMVCCMetadataKey(keys.LocalRangePrefix)
end := engine.MakeMVCCMetadataKey(keys.LocalRangeMax)
if err := db.Iterate(start, end, printRangeDescriptor); err != nil {
return err
}
return nil
}
开发者ID:danieldeb,项目名称:cockroach,代码行数:17,代码来源:debug.go
示例10: runDebugRangeDescriptors
func runDebugRangeDescriptors(cmd *cobra.Command, args []string) error {
stopper := stop.NewStopper()
defer stopper.Stop()
if len(args) != 1 {
return errors.New("one argument required: dir")
}
db, err := openStore(cmd, args[0], stopper)
if err != nil {
return err
}
start := engine.MakeMVCCMetadataKey(keys.LocalRangePrefix)
end := engine.MakeMVCCMetadataKey(keys.LocalRangeMax)
return db.Iterate(start, end, printRangeDescriptor)
}
开发者ID:yangxuanjia,项目名称:cockroach,代码行数:18,代码来源:debug.go
示例11: Set
func (k *mvccKey) Set(value string) error {
var typ keyType
var keyStr string
i := strings.IndexByte(value, ':')
if i == -1 {
keyStr = value
} else {
var err error
typ, err = parseKeyType(value[:i])
if err != nil {
return err
}
keyStr = value[i+1:]
}
switch typ {
case raw:
*k = mvccKey(engine.MakeMVCCMetadataKey(roachpb.Key(keyStr)))
case human:
key, err := keys.UglyPrint(keyStr)
if err != nil {
return err
}
*k = mvccKey(engine.MakeMVCCMetadataKey(key))
case rangeID:
fromID, err := parseRangeID(keyStr)
if err != nil {
return err
}
*k = mvccKey(engine.MakeMVCCMetadataKey(keys.MakeRangeIDPrefix(fromID)))
default:
return fmt.Errorf("unknown key type %s", typ)
}
return nil
}
开发者ID:yangxuanjia,项目名称:cockroach,代码行数:36,代码来源:context.go
示例12: copySeqCache
func copySeqCache(
e engine.Engine,
ms *engine.MVCCStats,
srcID, dstID roachpb.RangeID,
keyMin, keyMax engine.MVCCKey,
) (int, error) {
var scratch [64]byte
var count int
var meta engine.MVCCMetadata
// TODO(spencer): look into making this an MVCCIteration and writing
// the values using MVCC so we can avoid the ugliness of updating
// the MVCCStats by hand below.
err := e.Iterate(keyMin, keyMax,
func(kv engine.MVCCKeyValue) (bool, error) {
// Decode the key, skipping on error. Otherwise, write it to the
// corresponding key in the new cache.
txnID, err := decodeAbortCacheMVCCKey(kv.Key, scratch[:0])
if err != nil {
return false, util.Errorf("could not decode an abort cache key %s: %s", kv.Key, err)
}
key := keys.AbortCacheKey(dstID, txnID)
encKey := engine.MakeMVCCMetadataKey(key)
// Decode the MVCCMetadata value.
if err := proto.Unmarshal(kv.Value, &meta); err != nil {
return false, util.Errorf("could not decode mvcc metadata %s [% x]: %s", kv.Key, kv.Value, err)
}
value := meta.Value()
value.ClearChecksum()
value.InitChecksum(key)
meta.RawBytes = value.RawBytes
keyBytes, valBytes, err := engine.PutProto(e, encKey, &meta)
if err != nil {
return false, err
}
count++
if ms != nil {
ms.SysBytes += keyBytes + valBytes
ms.SysCount++
}
return false, nil
})
return count, err
}
开发者ID:GitGoldie,项目名称:cockroach,代码行数:44,代码来源:abort_cache.go
示例13: verifyCleanup
func verifyCleanup(key roachpb.Key, coord *TxnCoordSender, eng engine.Engine, t *testing.T) {
util.SucceedsWithin(t, 500*time.Millisecond, func() error {
coord.Lock()
l := len(coord.txns)
coord.Unlock()
if l != 0 {
return fmt.Errorf("expected empty transactions map; got %d", l)
}
meta := &engine.MVCCMetadata{}
ok, _, _, err := eng.GetProto(engine.MakeMVCCMetadataKey(key), meta)
if err != nil {
return fmt.Errorf("error getting MVCC metadata: %s", err)
}
if ok && meta.Txn != nil {
return fmt.Errorf("found unexpected write intent: %s", meta)
}
return nil
})
}
开发者ID:kimh,项目名称:cockroach,代码行数:19,代码来源:txn_coord_sender_test.go
示例14: makeReplicaKeyRanges
func makeReplicaKeyRanges(d *roachpb.RangeDescriptor) []keyRange {
// The first range in the keyspace starts at KeyMin, which includes the
// node-local space. We need the original StartKey to find the range
// metadata, but the actual data starts at LocalMax.
dataStartKey := d.StartKey.AsRawKey()
if d.StartKey.Equal(roachpb.RKeyMin) {
dataStartKey = keys.LocalMax
}
return []keyRange{
{
start: engine.MakeMVCCMetadataKey(keys.MakeRangeIDPrefix(d.RangeID)),
end: engine.MakeMVCCMetadataKey(keys.MakeRangeIDPrefix(d.RangeID + 1)),
},
{
start: engine.MakeMVCCMetadataKey(keys.MakeRangeKeyPrefix(d.StartKey)),
end: engine.MakeMVCCMetadataKey(keys.MakeRangeKeyPrefix(d.EndKey)),
},
{
start: engine.MakeMVCCMetadataKey(dataStartKey),
end: engine.MakeMVCCMetadataKey(d.EndKey.AsRawKey()),
},
}
}
开发者ID:kaustubhkurve,项目名称:cockroach,代码行数:23,代码来源:replica_data_iter.go
示例15: TestGCQueueIntentResolution
// TestGCQueueIntentResolution verifies intent resolution with many
// intents spanning just two transactions.
func TestGCQueueIntentResolution(t *testing.T) {
defer leaktest.AfterTest(t)()
tc := testContext{}
tc.Start(t)
defer tc.Stop()
const now int64 = 48 * 60 * 60 * 1E9 // 2d past the epoch
tc.manualClock.Set(now)
txns := []*roachpb.Transaction{
newTransaction("txn1", roachpb.Key("0-00000"), 1, enginepb.SERIALIZABLE, tc.clock),
newTransaction("txn2", roachpb.Key("1-00000"), 1, enginepb.SERIALIZABLE, tc.clock),
}
intentResolveTS := makeTS(now-intentAgeThreshold.Nanoseconds(), 0)
txns[0].OrigTimestamp = intentResolveTS
txns[0].Timestamp = intentResolveTS
txns[1].OrigTimestamp = intentResolveTS
txns[1].Timestamp = intentResolveTS
// Two transactions.
for i := 0; i < 2; i++ {
// 5 puts per transaction.
// TODO(spencerkimball): benchmark with ~50k.
for j := 0; j < 5; j++ {
pArgs := putArgs(roachpb.Key(fmt.Sprintf("%d-%05d", i, j)), []byte("value"))
if _, err := tc.SendWrappedWith(roachpb.Header{
Txn: txns[i],
}, &pArgs); err != nil {
t.Fatalf("%d: could not put data: %s", i, err)
}
txns[i].Sequence++
}
}
cfg, ok := tc.gossip.GetSystemConfig()
if !ok {
t.Fatal("config not set")
}
// Process through a scan queue.
gcQ := newGCQueue(tc.gossip)
if err := gcQ.process(tc.clock.Now(), tc.rng, cfg); err != nil {
t.Fatal(err)
}
// Iterate through all values to ensure intents have been fully resolved.
meta := &enginepb.MVCCMetadata{}
err := tc.store.Engine().Iterate(engine.MakeMVCCMetadataKey(roachpb.KeyMin),
engine.MakeMVCCMetadataKey(roachpb.KeyMax), func(kv engine.MVCCKeyValue) (bool, error) {
if !kv.Key.IsValue() {
if err := proto.Unmarshal(kv.Value, meta); err != nil {
return false, err
}
if meta.Txn != nil {
return false, util.Errorf("non-nil Txn after GC for key %s", kv.Key)
}
}
return false, nil
})
if err != nil {
t.Fatal(err)
}
}
开发者ID:csdigi,项目名称:cockroach,代码行数:65,代码来源:gc_queue_test.go
示例16: TestGCQueueProcess
//.........这里部分代码省略.........
if datum.del {
dArgs := deleteArgs(datum.key)
var txn *roachpb.Transaction
if datum.txn {
txn = newTransaction("test", datum.key, 1, enginepb.SERIALIZABLE, tc.clock)
txn.OrigTimestamp = datum.ts
txn.Timestamp = datum.ts
}
if _, err := tc.SendWrappedWith(roachpb.Header{
Timestamp: datum.ts,
Txn: txn,
}, &dArgs); err != nil {
t.Fatalf("%d: could not delete data: %s", i, err)
}
} else {
pArgs := putArgs(datum.key, []byte("value"))
var txn *roachpb.Transaction
if datum.txn {
txn = newTransaction("test", datum.key, 1, enginepb.SERIALIZABLE, tc.clock)
txn.OrigTimestamp = datum.ts
txn.Timestamp = datum.ts
}
if _, err := tc.SendWrappedWith(roachpb.Header{
Timestamp: datum.ts,
Txn: txn,
}, &pArgs); err != nil {
t.Fatalf("%d: could not put data: %s", i, err)
}
}
}
cfg, ok := tc.gossip.GetSystemConfig()
if !ok {
t.Fatal("config not set")
}
// Process through a scan queue.
gcQ := newGCQueue(tc.gossip)
if err := gcQ.process(tc.clock.Now(), tc.rng, cfg); err != nil {
t.Fatal(err)
}
expKVs := []struct {
key roachpb.Key
ts hlc.Timestamp
}{
{key1, ts5},
{key1, ts2},
{key2, ts5},
{key2, ts2m1},
{key3, hlc.ZeroTimestamp},
{key3, ts5},
{key3, ts2},
{key4, ts2},
{key6, hlc.ZeroTimestamp},
{key6, ts5},
{key6, ts1},
{key7, hlc.ZeroTimestamp},
{key7, ts4},
{key7, ts2},
{key8, ts2},
{key10, ts5},
{key10, ts4},
{key10, ts3},
{key11, ts5},
{key11, ts4},
{key11, ts3},
{key11, ts1},
}
// Read data directly from engine to avoid intent errors from MVCC.
kvs, err := engine.Scan(tc.store.Engine(), engine.MakeMVCCMetadataKey(key1),
engine.MakeMVCCMetadataKey(keys.MaxKey), 0)
if err != nil {
t.Fatal(err)
}
for i, kv := range kvs {
if log.V(1) {
log.Infof("%d: %s", i, kv.Key)
}
}
if len(kvs) != len(expKVs) {
t.Fatalf("expected length %d; got %d", len(expKVs), len(kvs))
}
for i, kv := range kvs {
if !kv.Key.Key.Equal(expKVs[i].key) {
t.Errorf("%d: expected key %q; got %q", i, expKVs[i].key, kv.Key.Key)
}
if !kv.Key.Timestamp.Equal(expKVs[i].ts) {
t.Errorf("%d: expected ts=%s; got %s", i, expKVs[i].ts, kv.Key.Timestamp)
}
if log.V(1) {
log.Infof("%d: %s", i, kv.Key)
}
}
// Verify that the last verification timestamp was updated as whole range was scanned.
if _, err := tc.rng.getLastVerificationTimestamp(); err != nil {
t.Fatal(err)
}
}
开发者ID:csdigi,项目名称:cockroach,代码行数:101,代码来源:gc_queue_test.go
示例17: TestTxnCoordSenderGCWithCancel
// TestTxnCoordSenderGCWithCancel verifies that the coordinator cleans up extant
// transactions and intents after transaction context is cancelled.
func TestTxnCoordSenderGCWithCancel(t *testing.T) {
defer leaktest.AfterTest(t)()
s, sender := createTestDB(t)
defer s.Stop()
// Set heartbeat interval to 1ms for testing.
sender.heartbeatInterval = 1 * time.Millisecond
ctx, cancel := context.WithCancel(context.Background())
txn := client.NewTxn(ctx, *s.DB)
key := roachpb.Key("a")
if pErr := txn.Put(key, []byte("value")); pErr != nil {
t.Fatal(pErr)
}
// Now, advance clock past the default client timeout.
// Locking the TxnCoordSender to prevent a data race.
sender.Lock()
s.Manual.Set(defaultClientTimeout.Nanoseconds() + 1)
sender.Unlock()
txnID := *txn.Proto.ID
// Verify that the transaction is alive despite the timeout having been
// exceeded.
errStillActive := errors.New("transaction is still active")
// TODO(dan): Figure out how to run the heartbeat manually instead of this.
if err := util.RetryForDuration(1*time.Second, func() error {
// Locking the TxnCoordSender to prevent a data race.
sender.Lock()
_, ok := sender.txns[txnID]
sender.Unlock()
if !ok {
return nil
}
meta := &engine.MVCCMetadata{}
ok, _, _, err := s.Eng.GetProto(engine.MakeMVCCMetadataKey(key), meta)
if err != nil {
t.Fatalf("error getting MVCC metadata: %s", err)
}
if !ok || meta.Txn == nil {
return nil
}
return errStillActive
}); err != errStillActive {
t.Fatalf("expected transaction to be active, got: %v", err)
}
// After the context is cancelled, the transaction should be cleaned up.
cancel()
util.SucceedsSoon(t, func() error {
// Locking the TxnCoordSender to prevent a data race.
sender.Lock()
_, ok := sender.txns[txnID]
sender.Unlock()
if ok {
return util.Errorf("expected garbage collection")
}
return nil
})
verifyCleanup(key, sender, s.Eng, t)
}
开发者ID:JKhawaja,项目名称:cockroach,代码行数:65,代码来源:txn_coord_sender_test.go
示例18: ClearData
// ClearData removes all persisted items stored in the cache.
func (sc *AbortCache) ClearData(e engine.Engine) error {
_, err := engine.ClearRange(e, engine.MakeMVCCMetadataKey(sc.min()), engine.MakeMVCCMetadataKey(sc.max()))
return err
}
开发者ID:GitGoldie,项目名称:cockroach,代码行数:5,代码来源:abort_cache.go
示例19: RunGC
//.........这里部分代码省略.........
TxnMeta: *meta.Txn,
}
txnMap[txnID] = txn
infoMu.IntentsConsidered++
intentSpanMap[txnID] = append(intentSpanMap[txnID], roachpb.Span{Key: expBaseKey})
}
// With an active intent, GC ignores MVCC metadata & intent value.
startIdx = 2
}
// See if any values may be GC'd.
if gcTS := gc.Filter(keys[startIdx:], vals[startIdx:]); !gcTS.Equal(roachpb.ZeroTimestamp) {
// TODO(spencer): need to split the requests up into
// multiple requests in the event that more than X keys
// are added to the request.
gcKeys = append(gcKeys, roachpb.GCRequest_GCKey{Key: expBaseKey, Timestamp: gcTS})
}
}
}
}
// Iterate through the keys and values of this replica's range.
for ; iter.Valid(); iter.Next() {
iterKey := iter.Key()
if !iterKey.IsValue() || !iterKey.Key.Equal(expBaseKey) {
// Moving to the next key (& values).
processKeysAndValues()
expBaseKey = iterKey.Key
if !iterKey.IsValue() {
keys = []engine.MVCCKey{iter.Key()}
vals = [][]byte{iter.Value()}
continue
}
// An implicit metadata.
keys = []engine.MVCCKey{engine.MakeMVCCMetadataKey(iterKey.Key)}
// A nil value for the encoded MVCCMetadata. This will unmarshal to an
// empty MVCCMetadata which is sufficient for processKeysAndValues to
// determine that there is no intent.
vals = [][]byte{nil}
}
keys = append(keys, iter.Key())
vals = append(vals, iter.Value())
}
if iter.Error() != nil {
return nil, GCInfo{}, iter.Error()
}
// Handle last collected set of keys/vals.
processKeysAndValues()
infoMu.IntentTxns = len(txnMap)
infoMu.GCKeys = len(gcKeys)
txnKeys, err := processTransactionTable(ctx, snap, desc, txnMap, txnExp, &infoMu, resolveIntents)
if err != nil {
return nil, GCInfo{}, err
}
// From now on, all newly added keys are range-local.
// TODO(tschottdorf): Might need to use two requests at some point since we
// hard-coded the full non-local key range in the header, but that does
// not take into account the range-local keys. It will be OK as long as
// we send directly to the Replica, though.
gcKeys = append(gcKeys, txnKeys...)
// Process push transactions in parallel.
var wg sync.WaitGroup
sem := make(chan struct{}, gcTaskLimit)
开发者ID:chzyer-dev,项目名称:cockroach,代码行数:67,代码来源:gc_queue.go
示例20: process
//.........这里部分代码省略.........
TxnMeta: *meta.Txn,
}
txnMap[txnID] = txn
intentCount++
intentSpanMap[txnID] = append(intentSpanMap[txnID], roachpb.Span{Key: expBaseKey})
}
// With an active intent, GC ignores MVCC metadata & intent value.
startIdx = 2
}
// See if any values may be GC'd.
if gcTS := gc.Filter(keys[startIdx:], vals[startIdx:]); !gcTS.Equal(roachpb.ZeroTimestamp) {
// TODO(spencer): need to split the requests up into
// multiple requests in the event that more than X keys
// are added to the request.
gcArgs.Keys = append(gcArgs.Keys, roachpb.GCRequest_GCKey{Key: expBaseKey, Timestamp: gcTS})
}
}
}
}
// Iterate through the keys and values of this replica's range.
for ; iter.Valid(); iter.Next() {
iterKey := iter.Key()
if !iterKey.IsValue() || !iterKey.Key.Equal(expBaseKey) {
// Moving to the next key (& values).
processKeysAndValues()
expBaseKey = iterKey.Key
if !iterKey.IsValue() {
keys = []engine.MVCCKey{iter.Key()}
vals = [][]byte{iter.Value()}
continue
}
// An implicit metadata.
keys = []engine.MVCCKey{engine.MakeMVCCMetadataKey(iterKey.Key)}
// A nil value for the encoded MVCCMetadata. This will unmarshal to an
// empty MVCCMetadata which is sufficient for processKeysAndValues to
// determine that there is no intent.
vals = [][]byte{nil}
}
keys = append(keys, iter.Key())
vals = append(vals, iter.Value())
}
if iter.Error() != nil {
return iter.Error()
}
// Handle last collected set of keys/vals.
processKeysAndValues()
gcq.eventLog.Infof(true, "assembled %d transactions from %d old intents; found %d gc'able keys", len(txnMap), intentCount, len(gcArgs.Keys))
txnKeys, err := gcq.processTransactionTable(repl, txnMap, txnExp)
if err != nil {
return err
}
// From now on, all newly added keys are range-local.
// TODO(tschottdorf): Might need to use two requests at some point since we
// hard-coded the full non-local key range in the header, but that does
// not take into account the range-local keys. It will be OK as long as
// we send directly to the Replica, though.
gcArgs.Keys = append(gcArgs.Keys, txnKeys...)
// Process push transactions in parallel.
var wg sync.WaitGroup
gcq.eventLog.Infof(true, "pushing %d txns", len(txnMap))
for _, txn := range txnMap {
if txn.Status != roachpb.PENDING {
开发者ID:cuongdo,项目名称:cockroach,代码行数:67,代码来源:gc_queue.go
注:本文中的github.com/cockroachdb/cockroach/storage/engine.MakeMVCCMetadataKey函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论