mirror of
https://github.com/FerretDB/documentdb.git
synced 2026-11-07 03:22:46 -05:00
### Does this PR have any customer impact? No ### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc) Logging ### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes) Yes ### Are you introducing any new config? If yes, do you have tests with and without them being set? Yes ### ChangeLog (Refer [Template](../oss/CHANGELOG.md)) NA ### Description - Add Pgmongo UDF to collect freespace metrics using `pg_freespamcemap` extension for all collection. - Use shared memory to store the next timestamp when freespace metrics should be collected which is 8 hours on the PG restarts and after one collection then set to next 24 hours, this is done to make sure we handle cases where PG might restart frequently. - The metrics are published per collection only if freespace available is more than the threshold defined by `pgmongo.freespace_metric_collection_threshold` which is defaulted to 30% - Each freespace metric collection happens for at most 60 secs and then the function returns so that we don't have long running metric collectors. The next log collection timestamp and collectionId are stored in shared memory.  ---- #### AI description (iteration 1) #### PR Classification This pull request introduces a new feature by adding UDFs and associated infrastructure to calculate and log freespace metrics for all collections. #### PR Summary The changes add C-based UDF functions that compute freespace metrics using the pg_freespacemap extension, integrate these metrics into telemetry logging, and provide tests and installation scripts to support the feature. - `pgmongo/src/utils/freespace_utils.c`: Adds C UDF implementations for calculating freespace metrics on both sharded and unsharded collections. - `pgmongo/src/infrastructure/mdsd_logger.c`: Implements functions to collect and log freespace metrics to the telemetry system. - `pgmongo/sql/udfs/telemetry/pgmongo_freespace_metrics--*.sql`: Introduces new SQL UDF definitions to expose freespace metric functionality. - `pgmongo/src/test/regress` and configuration files: Add regression tests, expected outputs, and update installation scripts (including Makefile and extension setup) to enable and verify the pg_freespacemap extension. <!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot --> Related work items: #4129539
20 lines
536 B
C
20 lines
536 B
C
/*-------------------------------------------------------------------------
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
*
|
|
* include/utils/data_table_utils.h
|
|
*
|
|
* Utilities for mongo feature usage tracking.
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
|
|
#ifndef DATA_TABLE_UTILS_H
|
|
#define DATA_TABLE_UTILS_H
|
|
|
|
ArrayType * GetCollectionIds(void);
|
|
ArrayType * GetCollectionIdsStartingFrom(uint64 startCollectionId);
|
|
void AlterCreationTime(void);
|
|
|
|
|
|
#endif /* DATA_TABLE_UTILS_H */
|