DocumentDB sync 20250226 by shuaitian-git · Pull Request #78 · documentdb/documentdb · GitHub
Skip to content

DocumentDB sync 20250226 - #78

Merged
safern merged 14 commits into
mainfrom
documentdbpush_02_26_03_42
Feb 26, 2025
Merged

safern merged 14 commits into
mainfrom
documentdbpush_02_26_03_42

Conversation

@shuaitian-git

Copy link
Copy Markdown
Contributor

Resolves #59
Resolves #61
Resolves #73

diipak-bisht and others added 14 commits February 26, 2025 03:42
### Does this PR have any customer impact?
Yes

### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Bugfix

### 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?
No

### ChangeLog (Refer [Template](../oss/CHANGELOG.md))

### Description
We noticed that with the latest release the metadata for reference table was not replicated in flex.
This PR bumps up the hotfix version for 1.22 and attempts to create the reference tables if not created already.

----
#### AI description  (iteration 1)
#### PR Classification
Bug fix to ensure reference tables are properly replicated in version 1.23-2.

#### PR Summary
This pull request addresses an issue where reference tables were not being replicated in version 1.23-1 of the `pgmongo` extension.
- Added `CheckAndReplicateReferrenceTable` function in `cluster_operations.c` to ensure reference tables are replicated.
- Updated `SetupCluster` function in `cluster_operations.c` to call the new replication check for specific tables.
- Added new regression tests in `extension_update_referencetable_1.23-2.sql` and `extension_update_referencetable_1.23-2.out` to verify the replication of reference tables.
- Updated `upgrade_schedule` to include the new test case for reference table replication.
- Added SHA1 checksum files for the new SQL upgrade scripts.
<!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
### 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

Fix seg fault on update from json schema changes

----
#### AI description  (iteration 1)
#### PR Classification
Bug fix

#### PR Summary
This pull request addresses a segmentation fault issue occurring during updates from JSON schema changes.
- `oss/pg_documentdb/src/commands/update.c`: Added a check to handle cases where the Mongo collection is not found, preventing potential segmentation faults.
<!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
…rom latest, fix idempotency of upgrade

### Does this PR have any customer impact?
No
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Infra
### 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?

### ChangeLog (Refer [Template](../oss/CHANGELOG.md))

### Description
If the extension is at a higher version and it rolls back to a previous schema, then we should skip downgrades to the schema by a default version.

----
#### AI description  (iteration 1)
#### PR Classification
Code enhancement to skip downgrading internal extensions from the latest version.

#### PR Summary
This pull request introduces a mechanism to skip downgrading internal extensions if they are already at the latest version.
- `src/infrastructure/process_utility_hook.c`: Added logic to check and skip downgrading if the installed version is newer than the target version.
- `src/pgmongo.c`: Introduced a new configuration variable `pgmongo.skip_extension_downgrade_check` to control the downgrade check behavior.
- `src/test/regress/sql/extension_upgrade_cluster_version.sql` and `src/test/regress/expected/extension_upgrade_cluster_version.out`: Added tests to verify the new behavior of skipping downgrades.
- `src/test/regress/bin/normalize.sed`: Updated normalization script to handle new version format in test outputs.
<!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
…with DocumentDB Tables

### Does this PR have any customer impact?
No

### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Features

### 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))

### Description
- Add support for a top level current_op command that calls the aggregation function and forms a command response
- Add support for joining between regular tables and documentdb tables. In this mode, we'll still require a query to be exclusively for find/aggregate etc, but we can put those queries in a CTE/Subquery and join with other find/aggregate/postgres queries and apply regular postgres join semantics.

----
#### AI description  (iteration 1)
#### PR Classification
New feature

#### PR Summary
This pull request introduces new features for handling `current_op` and joining with DocumentDB tables, including support for nested aggregation functions.
- Added `BuildAggregateSpecFromCommandSpec` and `command_current_op` functions in `src/commands/current_op.c` to handle new aggregation specifications.
- Implemented `MutateQueryAggregatorFunction` and `ExpandNestedAggregationFunction` in `src/planner/documents_planner.c` to support nested aggregation queries.
- Added new test cases in `src/test/regress/sql/bson_aggregation_functions_nested_tests.sql` and `src/test/regress/expected/bson_aggregation_functions_nested_tests.out`.
- Introduced feature flag `allowNestedAggregationFunctionInQueries` in `src/configs/feature_flag_configs.c` to control nested aggregation functionality.
- Created new UDFs in `sql/udfs/commands_diagnostic/current_op--0.102-0.sql` for the `currentOp` aggregation stage.
<!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
### Does this PR have any customer impact?
No

### 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
### ChangeLog (Refer [Template](../oss/CHANGELOG.md))

### Description
In CurrentOp for index builds, print stats on all shards (not just the top 1).

----
#### AI description  (iteration 1)
#### PR Classification
New feature

#### PR Summary
This pull request enhances the current operation reporting by including detailed index build statistics.
- `current_op.c`: Refactored to print all index build stats, including phase, blocks done, blocks total, and documents done/total.
- `current_op.c`: Added `PhaseToUserMessage` function to convert phase strings to user-friendly messages.
- `isolation-currentop-createindex.out`: Updated test output to include new index build stats.
- `isolation-setup.spec`: Modified test setup to check for new progress fields in the current operation output.
<!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
### Does this PR have any customer impact?
No

### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Infra

### 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
### ChangeLog (Refer [Template](../oss/CHANGELOG.md))

### Description
Setup initial infrastructure for building with Pg17.
Set up TODOs for work that's remaining
Disable tests and builds that don't yet work with Pg17.

----
#### AI description  (iteration 1)
#### PR Classification
New feature

#### PR Summary
This pull request adds support for building container images with PostgreSQL 17.
- `.pipelines/pgmongo_build_containers.yml`: Added a new stage `Build_PG17` to build PG17 images, including a job to build the Mariner base container image with PostgreSQL 17.
<!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
…match

### 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
[Bug-Fix] Update when query spec has regex.
While iterating query spec to find out if query has NonId filters, there was a bug due to that we were not using @@ filter in selectCandidate leads to incorrect match. Fixed Now

----
#### AI description  (iteration 1)
#### PR Classification
Bug fix to address issues with query specifications involving regex and right match.

#### PR Summary
This pull request fixes a bug related to handling regex in query specifications and updates.
- Added test cases in `commands_update.out` and `commands_update.sql` to verify regex operator and update functionality.
- Modified `bson_query.c` to correctly process filter functions involving regex patterns.
<!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
### Does this PR have any customer impact?
No

### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Infra

### 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?

### ChangeLog (Refer [Template](../oss/CHANGELOG.md))

### Description
- Updated pipeline common_variables.yml to point to latest build container tag
- Fix test output for picking up latest PG15/16 images
- Fix explains to be compatible with PG15/16/17
- Skip specific tests that fail wtih PG17 but run the rest
- Enable distributed tests for PG17 without the ones that fail
- Fix Flakey CollStats test

----
#### AI description  (iteration 2)
#### PR Classification
Code cleanup

#### PR Summary
Updated the build container image tag to use a normalized container tag for consistency.
- Modified `/.pipelines/templates/common_variables.yml` to replace a hardcoded build container image tag with `variables.NormalizedContainerTag`.
<!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
### Does this PR have any customer impact?
No

### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Testing

### 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?

### ChangeLog (Refer [Template](../oss/CHANGELOG.md))

### Description
Run Pgmongo Tests for PG17 as well.
Exclude tests that fail for now.

----
#### AI description  (iteration 1)
#### PR Classification
New feature: Add support for running tests with PostgreSQL 17.

#### PR Summary
This pull request updates the testing infrastructure to support running tests with PostgreSQL 17.
- `/oss/internal/pg_documentdb_distributed/src/test/regress/mutate_schedule.sh`: Refactored script to handle version-specific mutations and added support for PostgreSQL 17.
- `/pgmongo/src/test/regress/Makefile`: Updated to use the new mutation script and handle PostgreSQL 17 specific test schedules.
- `/.pipelines/pgmongo_backend_test.yml`: Enabled backend tests for PostgreSQL 17.
- `/pgmongo/src/metadata/oid_cache.c` and `/pgmongo/src/infrastructure/process_utility_hook.c`: Added conditional compilation to handle PostgreSQL 17 specific cases.
- Added new file `/pgmongo/src/test/regress/test_mutate_17` for PostgreSQL 17 specific test mutations.
<!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
### Does this PR have any customer impact?
No

### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Other

### 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
`documentdb.aggregation_stages_limit`- sets the max number of pipeline stages allowed in aggregations. (validates even the nested pipelines)

### ChangeLog (Refer [Template](../oss/CHANGELOG.md))
- Limit aggregation stages to 1000

### Description

Limit aggregation stages to 1000 via the GUC introduced.

This limit is enforced in newer server version > 7.1 , making it similar would have needed us to introduce api hooks as document db doesn't have server version. so we went ahead with simple GUC based approach to apply the limit, because this is rare limit to hit

----
#### AI description  (iteration 1)
#### PR Classification
New feature

#### PR Summary
This pull request introduces a limit on the number of aggregation stages in a pipeline to 1000 stages.
- `bson_aggregation_pipeline_private.h`: Added a helper function `CheckMaxAllowedAggregationStages` to enforce the stage limit.
- `bson_aggregation_pipeline.c`: Integrated the stage limit check within the `ExtractAggregationStages` function.
- `system_configs.c`: Defined a new configuration variable `aggregation_stages_limit` to set the maximum allowed stages.
- `bson_aggregation_pipeline_tests.sql` and `bson_aggregation_pipeline_tests.out`: Added tests to verify the stage limit enforcement.
- `documentdb_errors.h` and related error mapping files: Introduced a new error code for exceeding the stage limit.
<!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
…tch Function / Operator

### Does this PR have any customer impact? No

### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc) Feature

### 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; yes

### ChangeLog (Refer [Template](../oss/CHANGELOG.md))

### Description

Support `collation` with query operator using an internal UDF:
```
bson_query_match(document bson, query bson, collationString text, variableSpec bson)
```

Enable feature with `EnableCollationAndLetForQueryMatch` GUC.

Collation on sharded collections with collation-aware shard keys not supported yet.

----
#### AI description  (iteration 1)
#### PR Classification
New feature

#### PR Summary
This pull request adds collation support for query operators in the engine.
- `query_operator.c`: Added logic to handle collation strings in BSON query operators and expanded function to support collation and variable specifications.
- `metadata_cache.c`: Introduced a new function to get the OID of `bson_query_match` with collation and let arguments.
- `feature_flag_configs.c`: Added a new feature flag to enable collation and let for write commands.
- `bson_query_match--0.102.sql` and `bson_query_match--latest.sql`: Added new SQL functions to support collation in BSON queries.
- `documents_planner.c`: Updated planner to recognize and handle the new collation and let functionality in queries.
<!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
### 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
Rewriting query AST as per PG 17 changes and enabled output pipeline tests for PG 17

----
#### AI description  (iteration 1)
#### PR Classification
New feature: Enabling output pipelines for PostgreSQL 17.

#### PR Summary
This pull request enables output pipelines for PostgreSQL 17 by adding conditional compilation directives to handle new features in PG 17.
- `bson_aggregation_output_pipeline.c`: Added conditional logic to set `mergeJoinCondition` and `mergeTargetRelation` for PG 17.
- `test_mutate_17`: Updated test cases to reflect changes in aggregation stage and pipeline tests.
<!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
### 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
citus script:
line 46 throws error when ProcessCitusMakefileGlobal does not exist

libbson script:
save the downloaded file locally to avoid run tar command with incompleted file
@shuaitian-git
shuaitian-git requested review from a team as code owners February 26, 2025 03:45
@safern safern added this to the 0.102-0 milestone Feb 26, 2025
@safern
safern merged commit ad464ca into main Feb 26, 2025
@safern
safern deleted the documentdbpush_02_26_03_42 branch February 26, 2025 06:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fail to build against PostgreSQL 17 Joinin DocumentDB Collections with PostgreSQL Tables [Feature Request] currentOp command

7 participants