mirror of
https://github.com/FerretDB/documentdb.git
synced 2026-11-25 11:49:53 -05:00
* Merged PR 1565985: [OSS] Enable DBStats and CollStats in documentdb ### Does this PR have any customer impact? Yes ### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc) Refactor ### 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? No ### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md)) ### Description Enable DBStats, CollStats and indexStats in DocumentDB. These were partially broken due to their dependence on Citus. Add appropriate hooks to ensure that Distributed continues to work. Also clean up the code reuse of run_command_on_all_nodes across the 4 diagnostic commands. CurrentOp and index builds are also broken but will be tackled in a separate change. ---- #### AI description (iteration 1) #### PR Classification New feature #### PR Summary This pull request enables the `DBStats` and `CollStats` commands in DocumentDB. - `db_stats.c` and `coll_stats.c`: Refactored functions to retrieve shard OIDs and names, returning boolean status. - `distributed_hooks.c`: Added core function to get shard IDs and names for a collection. - Added new regression tests in `bson_aggregation_pipeline_diagnostic_command_tests.out` to validate `DBStats` and `CollStats` functionality. * Merged PR 1565678: Updated README to remove architecture images per PGCA guidelines ### Does this PR have any customer impact? No. ### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc) Documentation ### 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? No ### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md)) ### Description Per PGCA guidelines, we are temporarily removing the architecture image and replacing it with an approved one soon. ---- #### AI description (iteration 1) #### PR Classification Documentation update #### PR Summary This pull request updates the README to comply with PGCA guidelines by removing architecture images. - `oss/README.md`: Removed the architecture image. * DocumentDB sync sha=f3b8a6ec5 --------- Co-authored-by: Vinod Sridharan <visridha@microsoft.com> Co-authored-by: Patty Chow <patty.chow@microsoft.com>
85 lines
3.3 KiB
Bash
Executable File
85 lines
3.3 KiB
Bash
Executable File
#!/bin/bash
|
|
set -e -u
|
|
|
|
|
|
source="${BASH_SOURCE[0]}"
|
|
while [[ -h $source ]]; do
|
|
scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
|
|
source="$(readlink "$source")"
|
|
|
|
# if $source was a relative symlink, we need to resolve it relative to the path where the
|
|
# symlink file was located
|
|
[[ $source != /* ]] && source="$scriptroot/$source"
|
|
done
|
|
|
|
repoScriptDir="$( cd -P "$( dirname "$source" )" && pwd )"
|
|
|
|
function ValidateNoCitusReferences()
|
|
{
|
|
local _dir_to_check=$1
|
|
|
|
# TODO: Clean these up
|
|
validationExceptions="documentdb--0.24-0.sql create_index_background--0.23-0.sql create_index_background--latest.sql drop_indexes.c create_indexes_background.c"
|
|
validationExceptions="$validationExceptions current_op.c index.c ttl_support_functions--0.24-0.sql ttl_support_functions--latest.sql"
|
|
validationExceptions="$validationExceptions diagnostic_commands_common.c"
|
|
|
|
foundInvalid="";
|
|
for queryStr in "citus_" "pg_dist" "run_command_on_all_nodes" "run_command_on_coordinator"; do
|
|
for f in `grep -r -l -i -E $queryStr --include "*.h" --include "*.c" --include "*.sql" $_dir_to_check`; do
|
|
fileName=$(basename $f)
|
|
if [[ $validationExceptions =~ $fileName ]]; then
|
|
echo "Allowing $f as an exception for $queryStr"
|
|
continue;
|
|
fi;
|
|
|
|
echo "Remove references to $queryStr in $f - Please introduce a distributed hook to manage citus function execution"
|
|
foundInvalid="true"
|
|
done
|
|
done
|
|
|
|
if [ "$foundInvalid" != "" ]; then
|
|
echo "Found invalid citus references"
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
|
|
function CheckSqlLatestVersionMatchesLatestFile()
|
|
{
|
|
local _script_dir_prefix=$1
|
|
# check if the latest snapshot matches the latest 'version'
|
|
for script_dir in $repoScriptDir/../$_script_dir_prefix/sql/udfs/*; do
|
|
# Get the "latest" sql files:
|
|
for script_file in $( find "$script_dir" -iname "*--latest.sql" ); do
|
|
latest_file=$( basename $script_file );
|
|
file_base=${latest_file%--*};
|
|
|
|
# We want to find the last snapshotted sql file, to make sure it's the same
|
|
# as "latest.sql". This is done by:
|
|
# 1. Getting the filenames in the UDF directory (using find instead of ls, to keep shellcheck happy)
|
|
# 2. Filter out latest.sql
|
|
# 3. Sort using "version sort"
|
|
# 4. Get the last one using tail
|
|
latest_snapshot=$(\
|
|
find "$script_dir" -iname "$file_base--*.sql" -exec basename {} \; \
|
|
| { grep --invert-match latest.sql || true; } \
|
|
| sort --version-sort \
|
|
| tail --lines 1);
|
|
echo "Checking $latest_file against $latest_snapshot"
|
|
|
|
diff --unified "$script_dir/$latest_file" "$script_dir/$latest_snapshot";
|
|
done
|
|
done
|
|
}
|
|
|
|
# Ensure that citus references are done via hooks and not in the SQL/C files
|
|
ValidateNoCitusReferences $repoScriptDir/../pg_documentdb_core
|
|
ValidateNoCitusReferences $repoScriptDir/../pg_documentdb
|
|
|
|
# Validate sql files for the purposes of review and sanity.
|
|
CheckSqlLatestVersionMatchesLatestFile pg_documentdb_core
|
|
CheckSqlLatestVersionMatchesLatestFile pg_documentdb
|
|
CheckSqlLatestVersionMatchesLatestFile internal/pg_documentdb_distributed
|
|
|
|
# Ensure no header collisions
|
|
$repoScriptDir/validate_headers.sh |