MCPcopy Create free account
hub / github.com/documentdb/documentdb / InsertRetryRecord

Function InsertRetryRecord

pg_documentdb/src/commands/retryable_writes.c:312–456  ·  view source on GitHub ↗

* InsertRetryRecord inserts a retryable write record into the retry * table of a collection. */

Source from the content-addressed store, hash-verified

310 * table of a collection.
311 */
312void
313InsertRetryRecord(uint64 collectionId, int64 shardKeyValue, text *transactionId,
314 pgbson *objectId, bool rowsAffected, pgbson *resultDocument)
315{
316 StringInfoData query;
317 int spiStatus PG_USED_FOR_ASSERTS_ONLY = 0;
318
319 SPI_connect();
320
321 if (UseLocalRetryTable())
322 {
323 const int argCount = 6;
324 Oid argTypes[6];
325 Datum argValues[6];
326 char argNulls[] = { ' ', ' ', ' ', ' ', ' ', ' ' };
327
328 /*
329 * With a single shared retry table, all collections' retry records
330 * share the same index pages, which may cause buffer contention under
331 * heavy concurrent write workloads compared to per-collection retry
332 * tables. In practice this is expected to be low severity since retry
333 * records are short-lived.
334 */
335 initStringInfo(&query);
336 appendStringInfo(&query,
337 "INSERT INTO %s.retryable_writes"
338 " (collection_id, shard_key_value, transaction_id, object_id, "
339 " rows_affected, result_document) "
340 " VALUES ($1, $2, $3, $4::%s, $5, $6::%s)",
341 ApiDataSchemaName, FullBsonTypeName, FullBsonTypeName);
342
343 argTypes[0] = INT8OID;
344 argValues[0] = Int64GetDatum((int64) collectionId);
345
346 argTypes[1] = INT8OID;
347 argValues[1] = Int64GetDatum(shardKeyValue);
348
349 argTypes[2] = TEXTOID;
350 argValues[2] = PointerGetDatum(transactionId);
351
352 argTypes[3] = BYTEAOID;
353
354 if (objectId != NULL)
355 {
356 argValues[3] = PointerGetDatum(objectId);
357 argNulls[3] = ' ';
358 }
359 else
360 {
361 argNulls[3] = 'n';
362 }
363
364 argTypes[4] = BOOLOID;
365 argValues[4] = BoolGetDatum(rowsAffected);
366
367 argTypes[5] = BYTEAOID;
368
369 if (resultDocument != NULL)

Callers 3

DeleteOneInternalCoreFunction · 0.85

Calls 2

UseLocalRetryTableFunction · 0.85
GetSPIQueryPlanFunction · 0.85

Tested by

no test coverage detected