mirror of
https://github.com/FerretDB/documentdb.git
synced 2026-11-26 04:09:50 -05:00
### Does this PR have any customer impact? ### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc) ### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes) ### Are you introducing any new config? If yes, do you have tests with and without them being set? ### ChangeLog (Refer [Template](../oss/CHANGELOG.md)) ### Description ---- #### AI description (iteration 1) #### PR Classification Enhancement and bug fix to improve the stability and management of file-based cursors. #### PR Summary This pull request refactors and bolsters file-based cursor management by introducing shared memory support, improved cleanup, error handling, and configuration changes. It also adds new API endpoints and logging for better cursor lifecycle control. - **`cursor_store.c` and related files:** Added shared memory functions (e.g., `FileCursorShmemSize`, `InitializeFileCursorShmem`), cursor count regulation (with `IncrementCursorCount`/`DecrementCursorCount`), and cleanup routines to ensure stable cursor file operations. - **Test and expected output files:** Updated regression tests and expected outputs to cover scenarios like duplicate cursor creation, cursor deletion limits, and error reporting when the file cursor capacity is reached. - **API enhancements:** Introduced new UDFs (e.g., `command_delete_cursors`) and tenant client methods for killing and deleting cursors, improving session management. - **Configuration updates:** Renamed and added GUC parameters (e.g., `MaxAllowedCursorIntermediateFileSizeMB`, `MaxCursorFileCount`, and cursor expiry settings) to control file-based cursor behavior. - **Logging and metrics improvements:** Enhanced logging in `mdsd_logger.c` to report current cursor counts and related metrics for operational insight. <!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
33 lines
1.1 KiB
C
33 lines
1.1 KiB
C
/*-------------------------------------------------------------------------
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
*
|
|
* include/planner/documentdb_plan_cache.h
|
|
*
|
|
* Common declarations for the pg_documentdb plan cache.
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
|
|
#ifndef DOCUMENTDB_CURSOR_STORE_H
|
|
#define DOCUMENTDB_CURSOR_STORE_H
|
|
#include <postgres.h>
|
|
|
|
typedef struct CursorFileState CursorFileState;
|
|
|
|
void SetupCursorStorage(void);
|
|
void InitializeFileCursorShmem(void);
|
|
Size FileCursorShmemSize(void);
|
|
|
|
void DeletePendingCursorFiles(void);
|
|
void GetCurrentCursorCount(int32_t *currentCursorCount, int32_t *measuredCursorCount,
|
|
int64_t *lastCursorSize);
|
|
void DeleteCursorFile(const char *cursorName);
|
|
CursorFileState * CreateCursorFile(const char *cursorName);
|
|
void WriteToCursorFile(CursorFileState *cursorFileState, pgbson *bson);
|
|
pgbson * ReadFromCursorFile(CursorFileState *cursorFileState);
|
|
bytea * CursorFileStateClose(CursorFileState *cursorFileState);
|
|
|
|
CursorFileState * DeserializeFileState(bytea *cursorFileState);
|
|
|
|
#endif
|