cockroach: github.com/cockroachdb/cockroach/pkg/kv/kvserver/intentresolver Index | Files

package intentresolver

import "github.com/cockroachdb/cockroach/pkg/kv/kvserver/intentresolver"

Index

Package Files

intent_resolver.go metrics.go

type Config Uses

type Config struct {
    Clock                *hlc.Clock
    DB                   *kv.DB
    Stopper              *stop.Stopper
    AmbientCtx           log.AmbientContext
    TestingKnobs         kvserverbase.IntentResolverTestingKnobs
    RangeDescriptorCache kvbase.RangeDescriptorCache

    TaskLimit                    int
    MaxGCBatchWait               time.Duration
    MaxGCBatchIdle               time.Duration
    MaxIntentResolutionBatchWait time.Duration
    MaxIntentResolutionBatchIdle time.Duration
}

Config contains the dependencies to construct an IntentResolver.

type IntentResolver Uses

type IntentResolver struct {
    Metrics Metrics
    // contains filtered or unexported fields
}

IntentResolver manages the process of pushing transactions and resolving intents.

func New Uses

func New(c Config) *IntentResolver

New creates an new IntentResolver.

func (*IntentResolver) CleanupIntents Uses

func (ir *IntentResolver) CleanupIntents(
    ctx context.Context, intents []roachpb.Intent, now hlc.Timestamp, pushType roachpb.PushTxnType,
) (int, error)

CleanupIntents processes a collection of intents by pushing each implicated transaction using the specified pushType. Intents belonging to non-pending transactions after the push are resolved. On success, returns the number of resolved intents. On error, a subset of the intents may have been resolved, but zero will be returned.

func (*IntentResolver) CleanupIntentsAsync Uses

func (ir *IntentResolver) CleanupIntentsAsync(
    ctx context.Context, intents []roachpb.Intent, allowSyncProcessing bool,
) error

CleanupIntentsAsync asynchronously processes intents which were encountered during another command but did not interfere with the execution of that command. This occurs during inconsistent reads.

func (*IntentResolver) CleanupTxnIntentsAsync Uses

func (ir *IntentResolver) CleanupTxnIntentsAsync(
    ctx context.Context,
    rangeID roachpb.RangeID,
    endTxns []result.EndTxnIntents,
    allowSyncProcessing bool,
) error

CleanupTxnIntentsAsync asynchronously cleans up intents owned by a transaction on completion.

func (*IntentResolver) CleanupTxnIntentsOnGCAsync Uses

func (ir *IntentResolver) CleanupTxnIntentsOnGCAsync(
    ctx context.Context,
    rangeID roachpb.RangeID,
    txn *roachpb.Transaction,
    intents []roachpb.LockUpdate,
    now hlc.Timestamp,
    onComplete func(pushed, succeeded bool),
) error

CleanupTxnIntentsOnGCAsync cleans up extant intents owned by a single transaction, asynchronously (but returning an error if the IntentResolver's semaphore is maxed out). If the transaction is not finalized, but expired, it is pushed first to abort it. onComplete is called if non-nil upon completion of async task with the intention that it be used as a hook to update metrics. It will not be called if an error is returned.

func (*IntentResolver) MaybePushTransactions Uses

func (ir *IntentResolver) MaybePushTransactions(
    ctx context.Context,
    pushTxns map[uuid.UUID]*enginepb.TxnMeta,
    h roachpb.Header,
    pushType roachpb.PushTxnType,
    skipIfInFlight bool,
) (map[uuid.UUID]*roachpb.Transaction, *roachpb.Error)

MaybePushTransactions tries to push the conflicting transaction(s): either moving their timestamp forward on a read/write conflict, aborting it on a write/write conflict, or doing nothing if the transaction is no longer pending.

Returns a set of transaction protos who correspond to the pushed transactions and whose intents can now be resolved, and an error.

If skipIfInFlight is true, then no PushTxns will be sent and no intents will be returned for any transaction for which there is another push in progress. This should only be used by callers who are not relying on the side effect of a push (i.e. only pushType==PUSH_TOUCH), and who also don't need to synchronize with the resolution of those intents (e.g. asynchronous resolutions of intents skipped on inconsistent reads).

Callers are involved with a) conflict resolution for commands being executed at the Store with the

client waiting,

b) resolving intents encountered during inconsistent operations, and c) resolving intents upon EndTxn which are not local to the given range.

This is the only path in which the transaction is going to be in
non-pending state and doesn't require a push.

func (*IntentResolver) PushTransaction Uses

func (ir *IntentResolver) PushTransaction(
    ctx context.Context, pushTxn *enginepb.TxnMeta, h roachpb.Header, pushType roachpb.PushTxnType,
) (*roachpb.Transaction, *roachpb.Error)

PushTransaction takes a transaction and pushes its record using the specified push type and request header. It returns the transaction proto corresponding to the pushed transaction.

func (*IntentResolver) ResolveIntent Uses

func (ir *IntentResolver) ResolveIntent(
    ctx context.Context, intent roachpb.LockUpdate, opts ResolveOptions,
) *roachpb.Error

ResolveIntent synchronously resolves an intent according to opts.

func (*IntentResolver) ResolveIntents Uses

func (ir *IntentResolver) ResolveIntents(
    ctx context.Context, intents []roachpb.LockUpdate, opts ResolveOptions,
) *roachpb.Error

ResolveIntents synchronously resolves intents according to opts.

type Metrics Uses

type Metrics struct {
    // Intent resolver metrics.
    IntentResolverAsyncThrottled *metric.Counter
}

Metrics contains the metrics for the IntentResolver.

type ResolveOptions Uses

type ResolveOptions struct {
    Poison bool
    // The original transaction timestamp from the earliest txn epoch; if
    // supplied, resolution of intent ranges can be optimized in some cases.
    MinTimestamp hlc.Timestamp
}

ResolveOptions is used during intent resolution. It specifies whether the caller wants the call to block, and whether the ranges containing the intents are to be poisoned.

Package intentresolver imports 22 packages (graph) and is imported by 4 packages. Updated 2020-08-12. Refresh now. Tools for package owners.