Class SpannerWriterOptions
- All Implemented Interfaces:
Serializable
Set via SpannerSinkBuilder.writerOptions(SpannerWriterOptions); optional — every knob
is defaulted, so defaults() is equivalent to not setting options at all.
What the batch limits defend
A sink that accumulates mutations has to bound the request it builds, since a request Spanner
refuses is refused as a whole, taking every mutation in it with it. That much is correctness
rather than tidiness. Which limit each knob defends is narrower than three of them make
it look: Spanner documents no per-request mutation count for batch write at all, so SpannerWriterOptions.Builder.maxBatchBytes(long) is the one defending a documented request-level limit, and the other
two bound the request as a proxy for its size. How large that size limit is can be read two ways,
and the ceiling below takes the looser one. docs/adr/0077 carries the documentation rows
this rests on.
SpannerWriterOptions.Builder.maxBatchCells(int) is counted the way Spanner counts a mutation: a written
column costs one cell for the table plus one for every secondary index containing it, read from
the database's INFORMATION_SCHEMA when the writer opens. On a wide row that is a better
proxy for the request's size than a count of mutations would be.
The defaults are Apache Beam's, and Beam batches for Commit rather than for batch
write — which is where the commit-shaped figures entered this connector. They sit far under every
reading of every limit all the same.
Why there are recovery knobs at all
Unlike every other Google client this project builds on, the Spanner client does not
retry the RPC this sink writes with: SpannerStubSettings configures batchWrite
with an empty retryable-code set (checked against google-cloud-spanner 6.120.0), and the only
retry around it re-creates a lost session. So the sink owns the whole retry loop — the Cloud
Tasks shape rather than the Bigtable one — and these knobs budget it.
Instances are immutable and serializable.
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longThe defaultSpannerWriterOptions.Builder.maxBatchBytes(long): Beam's value, 1 MiB.static final intThe defaultSpannerWriterOptions.Builder.maxBatchCells(int): Beam's value, and 16 times under the 80,000 ceiling, so the headroom absorbs a schema whose indexes the writer could not read — and, should Spanner enforce a per-request mutation count it does not document, keeps an undercounted batch under that too.static final intThe defaultSpannerWriterOptions.Builder.maxBatchMutations(int): Beam's value.static final DurationThe largestSpannerWriterOptions.Builder.maxCommitDelay(Duration)Spanner accepts. -
Method Summary
Modifier and TypeMethodDescriptionstatic SpannerWriterOptions.Builderbuilder()Creates a newSpannerWriterOptions.Builder.static SpannerWriterOptionsdefaults()booleanReturns the timeout for one complete batch write attempt.longReturns the cap on the estimated size of a batch write request.intReturns the cap on mutation cells per batch write request, index entries included.intReturns the cap on mutations per batch write request.Returns the commit delay, ornullto leave the service's own handling in place.Returns the first backoff of the writer's retry loop.intReturns the maximum attempts of the writer's retry loop.Returns the backoff cap of the writer's retry loop.Returns the RPC priority, ornullto leave it unspecified (meaning high).inthashCode()Returns the retry schedule therecovery*knobs describe.toString()
-
Field Details
-
DEFAULT_MAX_BATCH_CELLS
public static final int DEFAULT_MAX_BATCH_CELLSThe defaultSpannerWriterOptions.Builder.maxBatchCells(int): Beam's value, and 16 times under the 80,000 ceiling, so the headroom absorbs a schema whose indexes the writer could not read — and, should Spanner enforce a per-request mutation count it does not document, keeps an undercounted batch under that too.- See Also:
-
DEFAULT_MAX_BATCH_MUTATIONS
public static final int DEFAULT_MAX_BATCH_MUTATIONSThe defaultSpannerWriterOptions.Builder.maxBatchMutations(int): Beam's value.- See Also:
-
DEFAULT_MAX_BATCH_BYTES
public static final long DEFAULT_MAX_BATCH_BYTESThe defaultSpannerWriterOptions.Builder.maxBatchBytes(long): Beam's value, 1 MiB.- See Also:
-
MAX_COMMIT_DELAY_LIMIT
The largestSpannerWriterOptions.Builder.maxCommitDelay(Duration)Spanner accepts. Rejected here rather than by the service, which would fail the write on a task manager rather than the job on submission.
-
-
Method Details
-
builder
Creates a newSpannerWriterOptions.Builder.- Returns:
- a new builder
-
defaults
Returns the default options: at most 5000 mutation cells, 500 mutations and 1 MiB per batch write request, the service's own commit delay and priority, a 30 s timeout for one complete batch write attempt, and a recovery budget of 500 ms doubling to 10 s over at most 10 attempts.- Returns:
- the default options
-
getMaxBatchCells
public int getMaxBatchCells()Returns the cap on mutation cells per batch write request, index entries included. -
getMaxBatchMutations
public int getMaxBatchMutations()Returns the cap on mutations per batch write request. -
getMaxBatchBytes
public long getMaxBatchBytes()Returns the cap on the estimated size of a batch write request. -
getMaxCommitDelay
Returns the commit delay, ornullto leave the service's own handling in place. -
getRpcPriority
Returns the RPC priority, ornullto leave it unspecified (meaning high). -
getBatchWriteTimeout
Returns the timeout for one complete batch write attempt. -
getRecoveryInitialBackoff
Returns the first backoff of the writer's retry loop. -
getRecoveryMaxBackoff
Returns the backoff cap of the writer's retry loop. -
getRecoveryMaxAttempts
public int getRecoveryMaxAttempts()Returns the maximum attempts of the writer's retry loop. -
toRecoverySchedule
Returns the retry schedule therecovery*knobs describe. Jittered: every subtask writing to a database that has just become unavailable retries on the same schedule, so unjittered they would all come back at the same instant. -
equals
-
hashCode
public int hashCode() -
toString
-