cockroach: Index | Files

package intentresolver

import ""


Package Files

contention_queue.go intent_resolver.go metrics.go

type CleanupFunc Uses

type CleanupFunc func(
    newWIErr *roachpb.WriteIntentError,
    newIntentTxn *enginepb.TxnMeta,

CleanupFunc is used to report the result of later writes in the face of WriteIntentError. It should never be called with both a newWIErr and a newIntentTxn.

type Config Uses

type Config struct {
    Clock                *hlc.Clock
    DB                   *client.DB
    Stopper              *stop.Stopper
    AmbientCtx           log.AmbientContext
    TestingKnobs         storagebase.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 is like maybePushIntents except it takes a set of transactions to push instead of a set of intents. This set of provided transactions may be modified by the method. It returns a set of transaction protos corresponding to the pushed transactions.

func (*IntentResolver) NumContended Uses

func (ir *IntentResolver) NumContended(key roachpb.Key) int

NumContended exists to ease writing tests at the storage level above which want to verify that contention is occurring within the IntentResolver.

func (*IntentResolver) ProcessWriteIntentError Uses

func (ir *IntentResolver) ProcessWriteIntentError(
    ctx context.Context, wiPErr *roachpb.Error, h roachpb.Header, pushType roachpb.PushTxnType,
) (CleanupFunc, *roachpb.Error)

ProcessWriteIntentError tries to push the conflicting transaction(s) responsible for the given WriteIntentError, and to resolve those intents if possible. Returns a cleanup function and potentially a new error to be used in place of the original. The cleanup function should be invoked by the caller after the request which experienced the conflict has completed with a parameter specifying a transaction in the event that the request left its own intent.

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 {
    // Resolve intents synchronously. When set to `false`, requests a
    // semi-synchronous operation, returning when all local commands have
    // been *proposed* but not yet committed or executed. This ensures that
    // if a waiting client retries immediately after calling this function,
    // it will not hit the same intents again.
    // TODO(bdarnell): Note that this functionality has been removed and
    // will be ignored, pending resolution of #8360.
    Wait   bool
    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 23 packages (graph) and is imported by 4 packages. Updated 2020-02-27. Refresh now. Tools for package owners.