mirror of
https://github.com/FerretDB/documentdb.git
synced 2026-11-25 19:59:54 -05:00
### Does this PR have any customer impact? Yes ### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc) Feature ### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes) No ### Are you introducing any new config? If yes, do you have tests with and without them being set? Yes ### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md)) ### Description The Gateway does a convoluted processing for maxTimeMS including having a second connection pool and creating transaction wrappers. Instead, this is simpler if this is moved into the backend and let the backend set custom timeouts directly. This part just codes up the backend piece and puts it behind a GUC. The Gateway changes will be made separately. ---- #### AI description (iteration 1) #### PR Classification Code improvement #### PR Summary This pull request improves command timeout handling by moving common command timeouts to the backend. - Added new test files `isolation-command_timeout.out` and `isolation-command_timeout.spec` to validate command timeout scenarios. - Modified `bson_aggregation_pipeline.c` to remove the `TryHandleSimplifyAggregationRequest` function. - Updated function signatures in `bson_aggregation_pipeline.h` to include `setStatementTimeout` parameter. - Adjusted `documents_planner.c` to handle the new `setStatementTimeout` parameter in various query generation functions.
87 lines
2.6 KiB
C
87 lines
2.6 KiB
C
/*-------------------------------------------------------------------------
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
*
|
|
* include/commands/commands_common.h
|
|
*
|
|
* Common declarations of Mongo commands.
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
|
|
#ifndef COMMANDS_COMMON_H
|
|
#define COMMANDS_COMMON_H
|
|
|
|
#include <utils/elog.h>
|
|
#include <metadata/collection.h>
|
|
#include <io/bson_core.h>
|
|
|
|
/*
|
|
* Maximum size of a output bson document is 16MB.
|
|
*/
|
|
#define BSON_MAX_ALLOWED_SIZE (16 * 1024 * 1024)
|
|
|
|
/*
|
|
* Maximum size of document produced by an intermediate stage of an aggregation pipeline.
|
|
* This is a Native Mongo constrains. For example, if the pipeline is [$facet, $unwind],
|
|
* $facet is allowed to generate document that is larger than 16MB, since $unwind can
|
|
* break them into smaller document. However, $facet is not allowed to generate a document
|
|
* that's larger than 100MB.
|
|
*/
|
|
#define BSON_MAX_ALLOWED_SIZE_INTERMEDIATE (100 * 1024 * 1024)
|
|
|
|
/* StringView that represents the _id field */
|
|
extern PGDLLIMPORT const StringView IdFieldStringView;
|
|
|
|
|
|
/*
|
|
* ApiGucPrefix.enable_create_collection_on_insert GUC determines whether
|
|
* an insert into a non-existent collection should create a collection.
|
|
*/
|
|
extern bool EnableCreateCollectionOnInsert;
|
|
|
|
/*
|
|
* Whether or not write operations are inlined or if they are dispatched
|
|
* to a remote shard. For single node scenarios like DocumentDB that don't need
|
|
* distributed dispatch. Reset in scenarios that need distributed dispatch.
|
|
*/
|
|
extern bool DefaultInlineWriteOperations;
|
|
extern int BatchWriteSubTransactionCount;
|
|
extern int MaxWriteBatchSize;
|
|
|
|
/*
|
|
* WriteError can be part of the response of a batch write operation.
|
|
*/
|
|
typedef struct WriteError
|
|
{
|
|
/* index in a write batch */
|
|
int index;
|
|
|
|
/* error code */
|
|
int code;
|
|
|
|
/* description of the error */
|
|
char *errmsg;
|
|
} WriteError;
|
|
|
|
|
|
bool FindShardKeyValueForDocumentId(MongoCollection *collection, pgbson *queryDoc,
|
|
bson_value_t *objectId, int64 *shardKeyValue);
|
|
|
|
bool IsCommonSpecIgnoredField(const char *fieldName);
|
|
|
|
WriteError * GetWriteErrorFromErrorData(ErrorData *errorData, int writeErrorIdx);
|
|
bool TryGetErrorMessageAndCode(ErrorData *errorData, int *code, char **errmessage);
|
|
|
|
pgbson * GetObjectIdFilterFromQueryDocument(pgbson *queryDoc, bool *hasNonIdFields);
|
|
|
|
|
|
pgbson * RewriteDocumentAddObjectId(pgbson *document);
|
|
pgbson * RewriteDocumentValueAddObjectId(const bson_value_t *value);
|
|
pgbson * RewriteDocumentWithCustomObjectId(pgbson *document,
|
|
pgbson *objectIdToWrite);
|
|
|
|
void ValidateIdField(const bson_value_t *idValue);
|
|
void SetExplicitStatementTimeout(int timeoutMilliseconds);
|
|
|
|
#endif
|