Commit Graph
502 Commits
Author SHA1 Message Date
Vinod Sridharan 491b8cd585 Merged PR 1541964: [OSS] Move all GUCs to a neutral prefix
### 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?

### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description
- Redo GUCs for helio -> documentdb preserving back-compat for the service.
- Move Docdb version to 1.24 -> 0.24

----
#### AI description  (iteration 1)
#### PR Classification
API change

#### PR Summary
This pull request updates the prefix for all GUCs (Grand Unified Configuration) to a neutral prefix.
- `documentdb_init.c`: Changed GUCs from "helio_api" to a dynamic prefix using `psprintf`.
- `documentdb_distributed_init.c` and `documentdb_distributed.c`: Updated GUCs to use a dynamic prefix.
- `pg_documentdb.c`, `pg_helio_api.c`, and `pgmongo.c`: Modified initialization functions to pass the new GUC prefix.
- `helio_api_init.h` and `helio_distributed_init.h`: Updated function signatures to include the new GUC prefix parameter.
- Updated control files to reflect the new version `0.24-0`.
2025-01-15 07:48:40 +00:00
Deepak Bisht c136836096 Merged PR 1537692: [Performance] Push Aggregates directly to shard for unsharded tables in single node
### Does this PR have any customer impact?
No

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

### 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))
- Push Aggregation queries directly to shard if the collection is unsharded in a single node and pipeline stages refer only 1 collection

### Description
Push Aggregation queries directly to shard if the collection is unsharded in a single node and pipeline stages refer only 1 collection

----
#### AI description  (iteration 1)
#### PR Classification
Performance improvement

#### PR Summary
This pull request optimizes the aggregation pipeline by pushing aggregates directly to shards for unsharded tables in a single node setup.
- Added tests in `bson_aggregation_pipeline_tests.out` to verify the new optimization for unsharded collections.
- Updated `bson_aggregation_pipeline_tests.out` in both `pg_helio_distributed` and `helio_compat` to include new test cases and EXPLAIN plans demonstrating the performance improvements.
2025-01-15 07:48:40 +00:00
Vinod Sridharan 17c1eda917 Merged PR 1540531: Fix cursor behavior for SRFs in Helio
### 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)
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

Cursors with SRFs caused crashes when not run via citus. Fix this behavior..

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

#### PR Summary
This pull request fixes an issue with cursor handling in the `HoldPortal` function.
- `cursors.c`: Ensures that the cursor options include `CURSOR_OPT_SCROLL` to support backwards scanning.
2025-01-15 07:48:40 +00:00
Lusen Dong ed860f8b6d Merged PR 1525182: [OSS] helio_api.validate different error code with mongo
### Does this PR have any customer impact?
No
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Bugfix
### 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
Expects MongoDB error code 73 with collection name has invalid type object message. Not MongoDB error code 26 (M0008).

postgres=# SELECT * FROM helio_api.validate('test','{"validate":{}}');
ERROR:  BSON field 'validate' is the wrong type 'object', expected type 'string'
postgres=# \errverbose
ERROR:  M0004: BSON field 'validate' is the wrong type 'object', expected type 'string'
LOCATION:  ThrowTopLevelTypeMismatchError, parse_error.h:24

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

#### PR Summary
This pull request addresses an issue with the `helio_api.validate` function returning an incorrect error code.
- Modified `oss/pg_helio_api/src/commands/validate.c` to check if the `validate` field is of type `BSON_TYPE_DOCUMENT` and return the appropriate error message and code.

Related work items: #3658791
2025-01-15 07:48:40 +00:00
Zinan Ren 8e7bd960bf Merged PR 1540262: [OSS] Remove helio references from sources of documentdb_core
### Does this PR have any customer impact?
No
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Refactoring
### 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
Remove helio from file name
Remove helio references from source content except schema reference
Start local documentdb server with the documentdb extension
Regression tests using the documentdb  extension

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

#### PR Summary
This pull request removes references to "helio" from the `documentdb_core` source code.
- `scripts/utils.sh`: Renamed variables from `preloadExtensions` to `preloadLibraries`.
- `pg_documentdb_core/include/utils/error_utils.h`: Updated function and macro names to replace "Helio" with "DocumentDB".
- `pg_documentdb_core/include/io/helio_bson_core.h` and `pg_documentdb_core/include/query/helio_bson_compare.h`: Moved to `pg_documentdb_core/include/io/bson_core.h` and `pg_documentdb_core/include/query/bson_compare.h`.
- `pg_documentdb_core/src/collation/collation.c` and `pg_documentdb_core/src/io/pgbson.c`: Replaced error codes and messages to use "DocumentDB" instead of "Helio".
- `scripts/validate_helio_extension_state.sh`: Added exceptions for certain files to skip validation for "helio" references.
2025-01-15 07:48:40 +00:00
Shuai Tian 19f20b4efb Merged PR 1540255: [OSS] remove dependencies on helio errors
### 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?

### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description

[OSS] remove dependencies on helio errors
2025-01-15 07:48:40 +00:00
Shuai Tian 5e6f0ac284 Merged PR 1539317: [OSS] remove mongo_data references
### 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?

### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description

[OSS] remove mongo_data references

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

#### PR Summary
This pull request removes references to `mongo_data` and replaces them with `documentdb_data` across the codebase.
- `collection.h`: Updated constants and macros to use `DOCUMENTDB` instead of `MONGO`.
- `drop_indexes.c`, `create_indexes.c`, `insert.c`: Replaced `MONGO_DATA` table and index format strings with `DOCUMENTDB_DATA`.
- `planner.c`, `bson_aggregation_output_pipeline.c`, `bson_aggregation_pipeline.c`: Updated attribute number constants and variable names.
- `index.h`: Changed index name format prefixes from `MONGO_DATA` to `DOCUMENTDB_DATA`.
- `shard_colocation.c`: Adjusted table prefix strings and comments to reflect the new naming convention.
2025-01-15 07:48:40 +00:00
Vinod Sridharan 3b609ecd8f Merged PR 1540011: [Add-node] More fixes for add-node scenarios
### 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)
No

### Are you introducing any new config? If yes, do you have tests with and without them being set?

### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description

- Cluster Data was not replicated fully on add node (upgrades would fail)
- Checks for index wasn't handled in add-node scenarios. (Create/Drop indexes would fail)
- Get versions on the GW on MX of the added node reutrns NullRef - fix these.

----
#### AI description  (iteration 1)
#### PR Classification
Bug fix for add-node scenarios.

#### PR Summary
This pull request addresses issues related to ensuring metadata tables are properly replicated during add-node operations.
- `distributed_hooks.c`: Refactored `EnsureMetadataTableReplicatedCore` to return a boolean and added `ExecuteMetadataChecksForReferenceTables`.
- `create_indexes_background.c`: Added checks to ensure metadata tables are replicated before starting index creation.
- `cluster_operations.c`: Ensured `cluster_data` table is replicated on all nodes during cluster setup.
- `api_hooks.c` and `api_hooks.h`: Modified `EnsureMetadataTableReplicated` to return a boolean indicating if replication occurred.
- `ExtensionVersionExtensions.cs`: Added null checks for version strings before writing them.
2025-01-15 07:48:39 +00:00
Parag Jain d3a92030fa Merged PR 1528481: [Perf] Optimize $merge "merge" option
### 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?

### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description
[Perf] Optimize $merge "merge" option

----
#### AI description  (iteration 1)
#### PR Classification
Performance optimization:

Single document in collection and  each entry is average of 10 runs.
![image.png](https://msdata.visualstudio.com/ba574a88-a171-48e0-8fcb-5fef6d23739c/_apis/git/repositories/501a5e7e-ffdc-4d1e-a5e6-910f73c6eb9a/pullRequests/1528481/attachments/image.png)

#### PR Summary
This pull request optimizes the `$merge` "merge" option by improving the handling of BSON elements.
- `bson_aggregation_output_pipeline.c`: Replaces the tree-based approach with a hash table to manage BSON elements, ensuring order and improving performance.
- Adds new functions and data structures for creating and managing an ordered hash set of BSON elements.
2025-01-15 07:48:39 +00:00
Vinod Sridharan 3f9a507562 Merged PR 1539950: [OSS] Move helio_api and helio_distributed sources under documentdb
### 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
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description
Move source files under new directory.

----
#### AI description  (iteration 1)
#### PR Classification
Code reorganization

#### PR Summary
This pull request moves the `helio_api` and `helio_distributed` sources under the `documentdb` directory, updating references and initialization logic accordingly.
- Added `pg_documentdb.c` for initializing the `pg_documentdb` extension.
- Added `documentdb_distributed.c` for initializing the `pg_documentdb_distributed` extension.
- Updated `validate_helio_extension_state.sh` to include new checks for `documentdb`.
- Moved `helio_api_extension_version.c` to `documentdb_extension_version.c` without code changes.
- Updated various `Makefile` configurations to reflect the new directory structure and dependencies.
2025-01-15 07:48:39 +00:00
Vinod Sridharan fd187e6b8f Merged PR 1539949: [Livesite] Fixups from cluster investigations
### Does this PR have any customer impact?
Yes

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

### 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
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description
1) The first DDL after add-node needs to replicate reference tables. Since we're already in a broken state, just use block_writes in this path (we can go faster in this path)
2) For back-compat scenarios in upgrade, add ALTER TABLE DROP CONSTRAINT IF EXISTS cluster_data_pkey in the next upgrade
3) Shard_collection broke the colocation of main and retry tables. Ensure that they are colocated under a guc.

Still TODO:
Create a new config collection for rebalance_table_shards_plan().

----
#### AI description  (iteration 1)
#### PR Classification
Bug fix and code improvement from cluster investigations.

#### PR Summary
This pull request addresses issues found during cluster investigations, focusing on retry table creation and sharding improvements.
- `create_collection_core.c`: Refactored to create a separate `CreateRetryTable` function and adjusted table creation logic.
- `sharding.c`: Added logic to recreate retry tables during sharding if the `RecreateRetryTableOnSharding` flag is enabled.
- `helio_api_init.c`: Introduced a new configuration variable `RecreateRetryTableOnSharding`.
- `command_shard_commands.sql` and `command_shard_commands.out`: Updated tests to validate the new retry table creation logic.
- `collection.h`: Added declaration for the new `CreateRetryTable` function.
2025-01-15 07:48:39 +00:00
Vinod Sridharan 5dc631ea31 Merged PR 1539132: [OSS] Move source files from pg_helio_core to pg_documentdb_core
### 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
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description
- Move c files from pg_helio_core -> pg_documentdb_core
- Make helio_core, and other extensions depend on pg_documentdb_core as a lib dependency

----
#### AI description  (iteration 1)
#### PR Classification
Code reorganization

#### PR Summary
This pull request moves source files from `pg_helio_core` to `pg_documentdb_core` to better organize the project structure.
- Deleted `oss/pg_helio_core/include/utils/helio_codes.txt`.
- Added `oss/pg_documentdb_core/src/pg_documentdb_core.c` for initializing the shared library.
- Updated `oss/Makefile.cflags` to include new paths and installation rules for `pg_documentdb_core`.
- Moved `oss/pg_helio_core/src/bson_init.c` and `oss/pg_helio_core/include/bson_init.h` to `oss/pg_documentdb_core/src/bson_init.c` and `oss/pg_documentdb_core/include/bson_init.h` respectively.
- Modified various `Makefile` files to set `USE_DOCUMENTDB_CORE` and adjust include paths.
2025-01-15 07:48:39 +00:00
Zinan Ren 4fbaacf659 Merged PR 1539352: [OSS] Add option for starting documentdb server
### Does this PR have any customer impact?
No
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Refactoring
### 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

Add [-t] - optional argument. serverType is the type of server to start.
Supported values are helio and documentdb, default is helio"

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

#### PR Summary
This pull request adds an option for starting a DocumentDB server and includes some script adjustments.
- Moved `oss/scripts/start_helio_server.sh` to `oss/scripts/start_oss_server.sh`.
- Updated `oss/scripts/utils.sh` to support additional preload extensions for PostgreSQL configurations.
2025-01-15 07:48:39 +00:00
Zinan Ren 892beac613 Merged PR 1539263: [OSS] Initial test setup for DocumentDB
### Does this PR have any customer impact?
No
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Refactoring
### 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

Add "make check" support into pg_documentdb, pg_documentdb_core, pg_documentdb_distributed
Add one test "public_api_schema.sql"

----
#### AI description  (iteration 1)
#### PR Classification
Initial test setup for DocumentDB.

#### PR Summary
This pull request sets up the initial testing framework for DocumentDB, including validation scripts and Makefile configurations.
- Added `validate_test_output.sh` scripts for both `pg_documentdb` and `pg_documentdb_distributed` to validate test outputs.
- Introduced custom diff tools (`diff` and `diff-filter`) in `pg_documentdb_distributed` for normalizing and comparing test results.
- Created `Makefile` for `pg_documentdb` and `pg_documentdb_distributed` to define test execution commands and configurations.
- Added `public_api_schema.out` files in `pg_documentdb` and `pg_documentdb_core` to validate the public API schema.
2025-01-15 07:48:39 +00:00
Vinod Sridharan dcf5344190 Merged PR 1538375: [OSS] Initial setup for documentdb
### 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)
Not yet

### 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
Initial setup for documentdb extensions.
Create Makefiles and set up build scripts around documentdb.

This does not yet touch the actual code or make anything deployable.

----
#### AI description  (iteration 1)
#### PR Classification
Initial setup for DocumentDB integration.

#### PR Summary
This pull request sets up the initial structure and configuration for DocumentDB integration.
- Added `documentdb_errors.h` for defining DocumentDB-specific error codes.
- Created `Makefile` for `pg_documentdb`, `pg_documentdb_core`, and `pg_documentdb_distributed` to handle build configurations.
- Updated `validate_helio_extension_state.sh` and `validate_headers.sh` scripts to include checks for DocumentDB.
- Modified `bson_aggregation_nested_pipeline.c`, `bson_aggregation_vector_search.c`, and other source files to replace references from Helio to DocumentDB.
- Added control files for `pg_documentdb`, `pg_documentdb_core`, and `pg_documentdb_distributed` extensions.
2025-01-15 07:48:39 +00:00
Parag Jain 8c8b0610d4 Merged PR 1537667: [Fix] Fix in PgbsonElement Hash Comparator
### 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?

### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description
Hash Comparator expected to return 0, +ve int and -ve int but but currently returning 0/1.

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

#### PR Summary
This pull request fixes the hash comparator function for `PgbsonElement` in the `pg_helio_core` module.
- `oss/pg_helio_core/src/utils/hashset_utils.c`: Corrected the comparison logic to handle path length and string comparison more accurately, ensuring proper hash entry comparison. Updated the function documentation to reflect the new return values.
2025-01-15 07:48:39 +00:00
Vinod Sridharan 0a2f28fdff Merged PR 1537573: Enable sharding commands and rebalancer commands
### Does this PR have any customer impact?
Yes

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

### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
Enable shard_collection, reshard_collection, unshard_collection with more mongo options.
Moves core processing of this to the backend.

also introduces shard rebalancing APIs

### Description

Enable shard_collection, reshard_collection, unshard_collection with more mongo options.
Moves core processing of this to the backend.

also introduces shard rebalancing APIs

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

#### PR Summary
This pull request enables sharding commands for pgmongo.
- `src/sharding/sharding.c`: Added functions to handle sharding, resharding, and unsharding collections, including `ShardCollectionLegacy`, `ShardCollectionCore`, `ParseNamespaceName`, `ParseShardCollectionRequest`, `ParseReshardCollectionRequest`, and `ParseUnshardCollectionRequest`.
2025-01-15 07:48:39 +00:00
Lucas Borges Fernandes b09275ac76 Merged PR 1514068: Unique index truncation recheck
### 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?
No.

### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description

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

#### PR Summary
This pull request addresses a bug related to unique index truncation by implementing a recheck mechanism.
- `oss/pg_helio_api/src/opclass/rum_exclusion.c`: Implemented `bson_unique_shard_path_equal` function to compare BSON documents for unique shard paths.
- Added `GetUniqueShardDocumentTermsHTAB` utility function to create a hash table of terms from a unique shard document.
- Adjusted include order and added new includes for required utilities.
- Changed `indexTermTruncateLimit` from `UINT32_MAX` to `INT32_MAX` in `generate_unique_shard_document`.

Related work items: #3291671, #3458782
2025-01-15 07:48:39 +00:00
Melody Wang (DEV) ✨ 31ff3c69e5 Merged PR 1438389: support $natural:-1 scenario
### 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)
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
support $natural:-1 scenario

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

#### PR Summary
This pull request adds support for the `$natural:-1` sort scenario in the aggregation pipeline.
- `src/aggregation/bson_aggregation_pipeline.c`: Added logic to handle `$natural` sort by introducing a `WindowClause` and using the `row_number()` function for sorting.
- Included necessary headers for function lookup and parsing.

Related work items: #3066471
2025-01-15 07:48:39 +00:00
Amit Prabhudesai c6783e2a49 Merged PR 1524148: [Bugfix] Fix handling of compound wildcard text indexes
### 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)
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
Handling of wildcard text indexes when compounded with a non-wildcard field is broken. This bug is a **functional bug** affecting query results when used with a wildcard index (see JS test for repro).

----
#### AI description  (iteration 1)
#### PR Classification
Bug fix to correct the handling of compound wildcard text indexes.

#### PR Summary
This pull request addresses a bug in the handling of compound wildcard text indexes by adding additional tests and correcting the index creation and listing logic.
- Modified `commands_create_indexes_text.out` to include more tests and correct the handling of compound wildcard text indexes.
- Added new test file `text_indexes_wildcard.js` to verify the correct behavior of wildcard text indexes.
- Updated `commands_create_indexes_text.sql` to include additional test cases for compound wildcard text indexes.
2025-01-15 07:48:39 +00:00
Rajesh Kumar Thandapani 504d57469e Merged PR 1489073: Historical change streams implementation
### Does this PR have any customer impact?
Yes it implements the option `StartAtOperationTimeStamp` for change streams.

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

### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description
This PR implements support for historical change streams using `StartAtOperationTimeStamp` option.

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

#### PR Summary
This pull request implements historical change streams with direct WAL decoding for MongoDB.
- `change_stream_wal_utils.c`: Added functions to determine the oldest available WAL segment and to check if a transaction is later than a given timestamp.
- `change_stream.h`: Removed `ChangeStreamSpec` struct and added `startTimestamp` to `ChangeStreamContext`.
- `change_stream_aggregation_stage.c`: Added support for `startAtOperationTime` to start change streams from a specific operation time.
- `change_stream_decoding_utils.c`: Added function to convert BSON timestamp to `TimestampTz`.

Related work items: #2973720
2025-01-15 07:48:39 +00:00
Patty fd8fb5ef46 Update CONTRIBUTING.md (#71) 2024-12-16 13:33:00 -06:00
Deepak Pemmaraju 19abafcc95 Merged PR 1511520: adding a limit of 10 users for dataplane user crud api
### 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?

### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description

adding a limit of 10 users for dataplane user crud api

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

#### PR Summary
This pull request enforces a limit of 10 users for the Dataplane user CRUD API.
- `oss/pg_helio_api/src/commands/users.c`: Added logic to check and enforce the maximum user limit before creating a new user.
- `oss/pg_helio_api/src/helio_api_init.c`: Introduced a new configuration variable `helio_api.maxUserLimit` to set the maximum number of users allowed.
- `pgmongo/src/test/regress/sql/user_crud_commands.sql` and `pgmongo/src/test/regress/expected/user_crud_commands.out`: Added tests to verify the user limit enforcement and behavior when the limit is exceeded.

Related work items: #3175767
2024-12-16 11:37:44 +08:00
Santiago Fernandez Madero e7d7e4cbe4 Merged PR 1525883: Push sort by _id down to the primary key index on unsharded or when we have a...
### 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?

### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description

Push sort by _id down to the primary key index on unsharded or when we have a shard key

----
#### AI description  (iteration 1)
#### PR Classification
Code optimization

#### PR Summary
This pull request optimizes the sorting mechanism by pushing the sort by `_id` down to the primary key index when applicable.
- Added `CanSortByObjectId` and `HasShardKeyFilterWalker` functions in `bson_aggregation_pipeline.c` to determine if sorting by `_id` can be optimized.
- Modified `HandleSort` function in `bson_aggregation_pipeline.c` to use the new optimization logic for sorting by `_id`.
- Updated function declarations in `bson_aggregation_pipeline.c` to include the new helper functions.
2024-12-16 11:37:44 +08:00
Vinod Sridharan 6169cfd57a Merged PR 1532251: [Update] Only do Upsert if the query is on _id
### Does this PR have any customer impact?
No

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

### 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
Fix up update to only do upsert if the query was exactly on _id. other cases should defer to insert (and fail on unique conflict)

----
#### AI description  (iteration 1)
#### PR Classification
Bug fix to ensure upsert operations are only performed when the query is on `_id`.

#### PR Summary
This pull request modifies the upsert logic to only perform upserts if the query is solely based on the `_id` field.
- Updated `update.c` to check for queries with only `_id` filters and renamed related variables for clarity.
- Added test cases in `commands_update.out` and `commands_update.sql` to verify upsert behavior and handle error cases.
2024-12-16 11:37:44 +08:00
Vinod Sridharan cb85775d7b Merged PR 1531437: Misc changes from service debugging
### Does this PR have any customer impact?
Yes
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Bug fixes
### 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?

### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description
1) send server group name in node metrics from backend
2) in collstats cap the avg obj size so it doesn’t go below storage size
3) skip run command on all nodes for single node
4) set the multinode behavior in distributed extension

----
#### AI description  (iteration 1)
#### PR Classification
Code cleanup and enhancement for service debugging.

#### PR Summary
This pull request includes various improvements and cleanups identified during service debugging.
- `pg_helio_distributed/src/test/regress/expected/commands_update.out`: Updated SQL command execution notices to use `helio_api_internal.update_worker`.
- `pgmongo/src/infrastructure/mdsd_logger.c`: Added functions to load default dimensions and append server group details to logs. Removed the `append_internal_logs` function.
2024-12-16 11:37:44 +08:00
Santiago Fernandez Madero 16bd9cad90 Merged PR 1528987: [Code cleanup] Remove dead code for old aggregation operator framework
### 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?

### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description

[Code cleanup] Remove dead code for old aggregation operator framework

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

#### PR Summary
This pull request removes dead code related to the old aggregation operator framework.
- Removed unused functions and variables in `src/operators/bson_expression.c`.
- Deleted legacy operator handling functions in `src/operators/bson_expression.c`.
- Cleaned up `include/operators/bson_expression_operators.h` by removing obsolete function declarations and typedefs.
- Updated `src/aggregation/bson_aggregation_nested_pipeline.c` to use the new aggregation expression evaluation functions.
- Removed legacy function declarations from `include/operators/bson_expression.h`.
2024-12-16 11:37:44 +08:00
Vinod Sridharan 215801d5cf Merged PR 1529060: [Tests] Fix don't ignore spaces in OSS tests (Part 2)
### 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?
No
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description
Don't ignore spaces in OSS tests - honor space changes as diffs

----
#### AI description  (iteration 1)
#### PR Classification
Bug fix for OSS tests to ensure spaces are not ignored.

#### PR Summary
This pull request addresses the issue of spaces being ignored in OSS tests by correcting the expected output formatting.
- `oss/internal/pg_helio_distributed/src/test/regress/expected/bson_aggregation_type_operators_tests.out`: Adjusted the expected output to include spaces in the `bson_dollar_project` results.
2024-12-16 11:37:44 +08:00
Vinod Sridharan 56e2a12845 Merged PR 1528566: Code Cleanup of Feature Flags
### 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
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description
- Delete old feature flags that are default on for a while.
- Remove ClusterVersion checks < 1.19

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

#### PR Summary
This pull request focuses on cleaning up feature flags in the codebase.
- Removed feature flag checks and related code in `bson_aggregation_pipeline.c`.
- Updated test outputs in `bson_aggregation_stage_merge_tests.out` files.
- Removed feature flag settings in `bson_index_truncation_index_tests.sql`.
- Deleted unused function `GetMergeDocumentsFunctionOid` in `bson_aggregation_pipeline_private.h`.
- Removed feature flag definitions in `helio_api_init.c`.
2024-12-16 11:37:44 +08:00
Parag Jain f6feaa4ea7 Merged PR 1494892: [Perf] [Update] Only shard_key And object_id filter for select candiadate for {_id : 1}
### 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?

### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description
When the query filter includes only the _id field with either the $eq or $in operator, we aim to optimize the update selection query by creating only two qualifiers: one on the shard_key_value and the other on the object_id column, while skipping the match on the document column.

This optimization reduces a few unnecessary calls; however, it does not yield a noticeable performance improvement because the TrimPrimaryKeyQuals function already removes useless qualifiers after the initial planning stage.

example :  `SELECT helio_api.update('update', '{"update":"updateme", "updates":[{"q":{"_id":{"$eq":1}},"u":{"$set":{"b":0 }},"multi":false}]}');`

- Before My Changes select query for update candidate
`SELECT ctid, object_id, document FROM mongo_data.documents_2_102046 WHERE shard_key_value = $1 AND document OPERATOR(mongo_catalog.@@) $2::mongo_catalog.bson AND object_id OPERATOR(mongo_catalog.=) $3`

 - After My changes
`SELECT ctid, object_id, document FROM mongo_data.documents_2_102046 WHERE shard_key_value = $1 AND object_id OPERATOR(mongo_catalog.=) $3::mongo_catalog.bson LIMIT 1 FOR UPDATE`

----

Why there is no noticeable perf changes  : As we already use `TrimPrimaryKeyQuals` function to remove useless quals after initial planning  even without my changes if we look at explain plan of select query :

```
EXPLAIN SELECT ctid, object_id, document FROM mongo_data.documents_2_102046 WHERE shard_key_value = 2 AND document OPERATOR(mongo_catalog.@@) '{"_id" : {"$eq" : 1}}'::mongo_catalog.bson AND object_id OPERATOR(mongo_catalog.=) '{ "" : { "$numberInt" : "1" } }';
                                                              QUERY PLAN
---------------------------------------------------------------------------------------------------------------------------------------
 Index Scan using _id_ on documents_2_102046  (cost=0.00..0.00 rows=1 width=40)
   Index Cond: ((shard_key_value = 2) AND (object_id OPERATOR(mongo_catalog.=) '{ "" : { "$numberInt" : "1" } }'::mongo_catalog.bson))
(2 rows)
```

```
postgres=# EXPLAIN SELECT ctid, object_id, document FROM mongo_data.documents_2_102046 WHERE shard_key_value = 2 AND document OPERATOR(mongo_catalog.@@) '{"_id" : {"$gt" : 1}}'::mongo_catalog.bson AND object_id OPERATOR(mongo_catalog.=) '{ "" : { "$numberInt" : "1" } }';
                                                              QUERY PLAN
------------------------------------------------------------------------------------------...
2024-12-16 11:37:44 +08:00
Vinod Sridharan f3783dff2d Merged PR 1526792: Fix up internal errors from error traces
### Does this PR have any customer impact?
Yes

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

### 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
1) In CollStats/DbStats we were missing teh prefix "ERROR" when looking at error messages: In distributed setups when the remote node fails, we end up with an error message that is "ERROR: out of memory". The initial ERROR: was not trimmed and so the response was always categorized as internal error - trim the prefix before checking the error.
2) Add retries for NpgsqlOperationInProgressException to avoid internal errors for this case
3) Bump up Npgsql to 9.0 - this has changes needed for improving error handling for buffer read overflows on errors

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

#### PR Summary
This pull request addresses internal error handling improvements and updates dependencies.
- `diagnostic_commands_common.c`: Added handling to strip "ERROR: " prefix from error messages.
- `PostgresClient.cs`: Added handling for `NpgsqlOperationInProgressException` to retry connections.
- `Packages.props`: Updated `Npgsql` package version from 8.0.3 to 9.0.1.
- `PostgresClientProvider.cs`: Changed type loading configuration to use `ConfigureTypeLoading`.
2024-12-16 11:37:44 +08:00
Vinod Sridharan 7a69840b4f Merged PR 1525667: [Misc Fixes] Fixes for Sharding and Update with Upsert
### Does this PR have any customer impact?
Yes

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

### 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 - to turn off the features

### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description
1) If there's a $or with shard key - extract the shard key values into the top level filter
2) If there's an update with an upsert, only do Upsert if hte query was on _id
3) Fix the query plan cache for insert/upsert

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

#### PR Summary
This pull request addresses issues related to sharding and updates with upsert functionality.
- `sharding.c`: Added functions to handle multi-value query predicates for shard keys, including `$and` and `$or` statements.
- `sharding.h`: Updated function declarations and added new functions for computing shard key expressions and creating shard key value filters.
- Added `query_sharding_tests.sql`: New test cases for various sharding scenarios.
- Updated `commands_update.out` and `helio_compat/commands_update.out`: Added tests for upsert error cases.
2024-12-03 17:42:24 +08:00
Santiago Fernandez Madero 8b017a7a42 Merged PR 1514383: Retry deadlock errors on update for concurrent update resiliency
### 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?

### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description

Retry deadlock errors on update for concurrent update resiliency.

a concurrent update of this nature would hit a deadlock:
t1-> update: {_id: 1, _id: 2}
t2-> update: {_id: 2, _id: 1}

While applications shouldn't do this, this adds resiliency, so tradeoff between latency vs errors.

Should we put this behind a GUC?

I'll add a test soon.

----
#### AI description  (iteration 1)
#### PR Classification
New feature to enhance concurrent update resiliency by retrying deadlock errors.

#### PR Summary
This pull request introduces a mechanism to retry deadlock errors during updates to improve concurrent update resiliency.
- `PostgresClient.cs`: Added `retryDeadlock` parameter to handle deadlock retries in various methods.
- `delete.c`, `insert.c`, `update.c`: Introduced `rethrowDeadlock` flag to manage deadlock errors in batch operations.
- `commands_common.c`, `commands_common.h`: Updated `GetWriteErrorFromErrorData` to support `rethrowDeadlock` flag for deadlock error handling.
2024-12-03 17:42:24 +08:00
Lucas Borges Fernandes 555181a2d9 Merged PR 1458242: Upgrading libbson to 1.28.0
### Does this PR have any customer impact?
No.

### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
N/A.

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

Upgrading libbson dependency.

----
#### AI description  (iteration 1)
#### PR Classification
Dependency upgrade

#### PR Summary
This pull request upgrades the `libbson` library to version 1.28.0 and updates related initialization code.
- Updated `MONGO_DRIVER_VERSION` to 1.28.0 in `oss/scripts/install_setup_libbson.sh`.
- Added a `NULL` entry to the `bson_mem_vtable_t` structure in `oss/pg_helio_core/src/bson_init.c`.

Related work items: #3468225
2024-12-03 17:42:24 +08:00
Shuai Tian d09aeb6aaf Merged PR 1516163: upgrade pgvector version to 0.8.0
### Does this PR have any customer impact?
No

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

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

upgrade pgvector version to 0.8.0
Temporarily comment out tests that have different results with new version, to avoid breaking the test pipelines after new docker image is used.

----
#### AI description  (iteration 1)
#### PR Classification
Bug fix for failing tests due to different versions of pgvector.

#### PR Summary
This pull request upgrades the pgvector version to 0.8.0 to address failing tests.
- Modified `bson_aggregation_pipeline_tests_vector_ivf.out` in `pg_helio_distributed` and `pgmongo` to temporarily disable specific tests until the pgvector upgrade is complete.
- Updated `commands_create_indexes_background.out` to temporarily disable tests related to vector index creation until the pgvector upgrade is complete.

Related work items: #3612979
2024-11-19 17:25:36 +08:00
Parag Jain 1ed1aac4a9 Merged PR 1499694: [Perf] [Update] [Minor] Adding Early Check
### Does this PR have any customer impact?
No
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Perf
### 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
[Perf] Adding early check for unshraded collection so that we don't need to convert pgbsonToBsonValue for unsharded collection.

----
2024-11-19 17:25:36 +08:00
Amit Prabhudesai 95910b3aa9 Merged PR 1512730: Add helio_distributed_test_helpers to helio_compat tests
### 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?
No

### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description
Add helio_distributed_test_helpers to helio_compat tests

Without this, tests that rely on `helio_distributed_test_helpers` (e.g., tests for background index builds) crap out with an error like so:

```
 CALL helio_distributed_test_helpers.create_indexes_background('db', '{ "createIndexes": "LargeKeySize", "indexes": [ { "key" : { "a": 1 }, "name": "rumConstraint1"}] }');
-                                                                                                                retval                                                                                                                | ok
----------------------------------------------------------------------
- { "raw" : { "defaultShard" : { "numIndexesBefore" : { "$numberInt" : "1" }, "numIndexesAfter" : { "$numberInt" : "2" }, "createdCollectionAutomatically" : false, "ok" : { "$numberInt" : "1" } } }, "ok" : { "$numberInt" : "1" } } | t
-(1 row)
-
+ERROR:  procedure helio_distributed_test_helpers.create_indexes_background(unknown, unknown) does not exist
+LINE 1: CALL helio_distributed_test_helpers.create_indexes_backgroun...
+             ^
+HINT:  No procedure matches the given name and argument types. You might need to add explicit type casts.
```

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

#### PR Summary
This pull request updates the test setup for `helio_compat` by adding a new test helper.
- `pgmongo/src/test/helio_compat/helio_setup_schedule`: Added `helio_distributed_test_helpers` to the test setup.
2024-11-19 17:25:36 +08:00
Duan Pei✨ cbd1780c97 Merged PR 1506905: [Fix] fix memory_check for maxN/minN
### 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?

### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description

update

----
#### AI description  (iteration 1)
#### PR Classification
Bug fix for memory check in maxN/minN aggregation functions.

#### PR Summary
This pull request addresses a bug in the memory check for maxN/minN aggregation functions by adding size validation and handling large element sizes.
- `bson_aggregates.c`: Added size validation for intermediate documents and updated element type handling to support int64.
- `bson_aggregation_pipeline_tests_maxnminn_group.out`: Added tests to verify the 100 MB limit for $maxN and $minN operations.
2024-11-19 17:25:36 +08:00
Vinod Sridharan df093213ad Merged PR 1511148: [Upsert] On Update with Upsert, convert the final insert to INSERT ON CONFLICT UPDATE
### 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)
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
On Update with Upsert, convert the final insert to INSERT ON CONFLICT UPDATE
This is to handle a race condition where two threads do SELECT for update -> don't find the doc -> one does the insert, and the other will get a unique conflict when it should just succeed.

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

#### PR Summary
This pull request introduces a new feature to handle upserts by converting the final insert to `INSERT ON CONFLICT UPDATE`.
- `oss/pg_helio_api/src/commands/insert.c`: Added `InsertOrUpdateDocument` function to handle upserts.
- `oss/pg_helio_api/src/commands/update.c`: Updated functions to use `InsertOrUpdateDocument` for upsert operations.
- `oss/pg_helio_api/include/commands/insert.h`: Declared the new `InsertOrUpdateDocument` function.
- `oss/internal/pg_helio_distributed/src/test/regress/expected/commands_update.out` and `pgmongo/src/test/helio_compat/expected/commands_update.out`: Added tests for the new upsert behavior.
- `oss/internal/pg_helio_distributed/src/test/regress/sql/commands_update.sql`: Added SQL tests for upsert functionality.
2024-11-19 17:25:36 +08:00
Cornelius Boateng 918504553e Merged PR 1511567: [pgmongo][let 5/n]Let Support for Inline Projection
### 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? No

### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description

Support let variables with inlin projection

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

#### PR Summary
This pull request adds support for inline projection in the aggregation pipeline.
- Modified `oss/pg_helio_api/src/aggregation/bson_project.c` to handle new function OIDs for inline projection and addFields with let variables.
- Updated test files `/oss/internal/pg_helio_distributed/src/test/regress/expected/bson_aggregation_pipeline_tests_let.out` and `/pgmongo/src/test/helio_compat/expected/bson_aggregation_pipeline_tests_let.out` to include new test cases for the inline projection feature.
- Added new SQL test cases in `/oss/internal/pg_helio_distributed/src/test/regress/sql/bson_aggregation_pipeline_tests_let.sql` to validate the new functionality.
2024-11-19 17:25:36 +08:00
Santiago Fernandez Madero 738f66ab62 Merged PR 1511256: Fix check-dist-minimal
### 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?

### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description

When check-dist-minimal initially was added it didn't include `helio_distributed_setup` so 2 commits in parallel attempted to fix this. One by including minimal_schedule to the make target: https://msdata.visualstudio.com/CosmosDB/_git/pgmongo/commit/36ace0cb18d7aed12de01f5e14d8ae3898e051ac?refName=refs%2Fheads%2Fusers%2Fdeepakbisht%2FfixMinimal

The other one by running `helio_distributed_setup` on the `minimal_schedule`: https://msdata.visualstudio.com/CosmosDB/_git/pgmongo/commit/6cb01bd1c3ca9ec2584e50b8fff6808562e660e1?refName=refs%2Fheads%2Fmain&path=%2Foss%2Finternal%2Fpg_helio_distributed%2Fsrc%2Ftest%2Fregress%2Fminimal_schedule&_a=compare

We should take the second one as for correctness `check-dist-minimal` should not use `basic_schedule` as that "runs more than just the actual setup + the extra test provided".

Also, this cleans up duplicated `check-dist-minimal` targets on the make files.

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

#### PR Summary
This pull request addresses a bug in the `check-dist-minimal` target.
- Removed `check-dist-minimal` target from `oss/internal/pg_helio_distributed/Makefile`
- Removed `check-dist-minimal` target from `oss/internal/pg_helio_distributed/src/test/regress/Makefile`
2024-11-19 17:25:36 +08:00
Jayanta Mondal e3d4ac5865 Merged PR 1510974: [Engine] Free ErrorData to avoid potential memory leak
### Does this PR have any customer impact?
No

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

### 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))
N/A

### Description

Freeing copy of  ErrorData objects after error message has been written into a palloced Response object.

We discovered this while investigating postgres crash caused by _S_TEMP_STR_ workload. The crash was solved by this: https://msdata.visualstudio.com/CosmosDB/_git/pgmongo/pullrequest/1497598

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

#### PR Summary
Fixes a memory leak issue by ensuring error data is properly freed after use.
- `src/commands/update.c`: Added `FreeErrorData(errorData)` to free error data after appending to `batchResult->writeErrors`.
2024-11-19 17:25:36 +08:00
Santiago Fernandez Madero b1e4bcb8f2 Merged PR 1509895: Fix oss index with public RUM after adding hooks to load custom handlers
### 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?

### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description

Fix oss index with public RUM after adding hooks to load custom handlers

After the hook change, the missingOk argument to load the function was set to false always, but we need to consider scenarios where we're using the public RUM (OSS), so the custom multiandgetbimap function would not be available.

![image.png](https://msdata.visualstudio.com/ba574a88-a171-48e0-8fcb-5fef6d23739c/_apis/git/repositories/501a5e7e-ffdc-4d1e-a5e6-910f73c6eb9a/pullRequests/1509895/attachments/image.png)

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

#### PR Summary
Fixes the issue with the OSS index when using public RUM by adding hooks to load custom handlers.
- `api_hooks.c`: Modified `GetMultiAndBitmapIndexFunc` to accept a `missingOk` parameter.
- `rum_custom_join_scan.c`: Updated `RegisterRumJoinScanNodes` to pass `missingOk` to `GetMultiAndBitmapIndexFunc`.
- `api_hooks.h`: Updated function declaration of `GetMultiAndBitmapIndexFunc` to include `missingOk` parameter.
2024-11-12 18:48:09 +08:00
Cornelius Boateng e62bdce75d Merged PR 1505458: [pgmongo][let 4/n] $groupBy with sorted accumulators on sharded collection
### 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? No

### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description
Support for Let on $groupBy with sorted accumulators.
Cast intermediate stage output from helio bson to catalog bson
2024-11-12 18:48:09 +08:00
Jia Hu 648d2fc575 Merged PR 1509422: Fix wiki formatting issue and debugging error with inline function
### Does this PR have any customer impact?
No
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
format
### 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))
No
### Description
fix document format and debug error with inline function

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

#### PR Summary
This pull request addresses a wiki formatting issue and a debugging error with an inline function.
- `schema_validation.h`: Changed the `CheckSchemaValidationEnabled` function from `inline` to `static inline`.
- `reference.md`: Fixed formatting issues by removing and adding backticks.
2024-11-12 18:48:09 +08:00
Zinan Ren 🐾 1e9746818f Merged PR 1487172: [Vector Search][Embedding Gen Part 1] Refactor update operators and search spec to support non-oss
### Does this PR have any customer impact?
Yes

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

### 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?
pgmongo.enableEmbeddingGeneration, default is false(feature disabled)

### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description
The goal of this feature is enable an inline embedding generation in vCore based on [azure_ai extension]
(https://learn.microsoft.com/en-us/azure/postgresql/flexible-server/generative-ai-azure-openai)

Related design doc [Inline embedding generation in vCore ](https://microsoftapc-my.sharepoint.com/:w:/g/personal/zhli2_microsoft_com/Ea2uDc0c0FBNr-fpoMdHIPUBJiA5yXZ-xRRNWGYEBqZ38Q?e=dQdU7i&ovuser=72f988bf-86f1-41af-91ab-2d7cd011db47%2Crongwa%40microsoft.com&clickparams=eyJBcHBOYW1lIjoiVGVhbXMtRGVza3RvcCIsIkFwcFZlcnNpb24iOiI0OS8yNDAzMTQxNDcxMiIsIkhhc0ZlZGVyYXRlZFVzZXIiOmZhbHNlfQ%3D%3D)
![image.png](https://msdata.visualstudio.com/ba574a88-a171-48e0-8fcb-5fef6d23739c/_apis/git/repositories/501a5e7e-ffdc-4d1e-a5e6-910f73c6eb9a/pullRequests/1339487/attachments/image.png)

- Feature Flag
**pgmongo.enableEmbeddingGeneration**

- Feature counter
**update_operator_vector_gen_embeddings**
**search_vector_gen_embeddings**

- Onboard AOAI resource([Part 3 PR](https://msdata.visualstudio.com/CosmosDB/_git/pgmongo/pullrequest/1478366))
```
SELECT create_distributed_table('azure_ai.settings','key');

SELECT azure_ai.set_setting('azure_openai.endpoint','https://localhost.openai.azure.com');
SELECT azure_ai.set_setting('azure_openai.subscription_key','<api-key-placeholder>');

ALTER SYSTEM SET pgmongo.azureOpenAIEmbeddingDeploymentName = 'text-embedding-ada-002';
SELECT pg_reload_conf();
SELECT run_command_on_workers('ALTER SYSTEM SET pgmongo.azureOpenAIEmbeddingDeploymentName = ''text-embedding-ada-002''');
SELECT run_command_on_workers('SELECT pg_reload_conf()');

```

- Update command
```
SELECT mongo_api_v1.update('db',
    '{"update":"generate_embedding_pipeline",
      "updates":[
             {"q":{},"u":{"**$generateEmbeddings**":{"a":"embeddings"}}, "multi":true}
      ]}'
);
```

- Vector search
```
SELECT document FROM bson_aggregation_pipeline('db',
     '{ "aggregate": "generate_embedding_pipeline",
        "pipeline": [
               { "$search": {
                         "cosmosSearch": { "query": "some sentence", "k": 4, "path": "embeddings", "efSearch": 2 }  }
                  } ,
               { "$count": "_id" }
        ],
        "cursor": {}
      }'
);
```

----
#### AI description  (iteration 1)
#### PR Classification
Refactor to support non-OSS embedding generation and vector search.

#### PR Summary
This pull request refactors update operations and search specifications to support embedding generation in non-OSS environments.
- Added `vector_g...
2024-11-12 18:48:09 +08:00
Zinan Ren 🐾 4742ecce61 Merged PR 1487201: [Vector Search][Embedding Gen Part 2] Integrate azure_ai extension and add local tests
### 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?
No

### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description

- Create azure_ai extension if it is available( in flex cluster)
- Add mock aoai server
- Add local only tests which will never be run in CI pipeline

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

#### PR Summary
This pull request integrates the `azure_ai` extension and adds local tests for embedding generation using a mock AOAI server.
- Added `scripts/mock_aoai/aoai_mock_server.py` to mock AOAI API server for local testing.
- Added `pgmongo/src/test/regress/sql/bson_aggregation_pipeline_tests_vector_gen_embedding.sql` and `pgmongo/src/test/regress/expected/bson_aggregation_pipeline_tests_vector_gen_embedding.out` for embedding generation tests.
- Updated `pgmongo/src/infrastructure/process_utility_hook.c` to check and create the `azure_ai` extension if available.
- Added `scripts/mock_aoai/setup_and_start_mock_server.sh` to set up and start the mock AOAI server.
- Modified `pgmongo/src/test/regress/Makefile` to include embedding generation tests with the mock server.
2024-11-12 18:48:09 +08:00
Lusen Dong 3f4fc51e8b Merged PR 1502018: [Bugfix] oss compilation error on Ubuntu 24.04
### Does this PR have any customer impact?
No
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Bugfix
### 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))
N/A
### Description

[Bugfix] address compilation error on Ubuntu 24.04

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

#### PR Summary
This pull request addresses a compilation error on Ubuntu 24.04.
- Modified `src/commands/delete.c` to remove redundant null checks for `collection->shardTableName`.

Related work items: #3584480
2024-11-12 18:48:09 +08:00
Parag Jain 48f3e026c2 Merged PR 1506658: [Bug-Fix] setting merge whenMatched default option to merge from replace
### 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?

### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description
[Bug-Fix] setting merge whenMatched default option to merge from replace
![image.png](https://msdata.visualstudio.com/ba574a88-a171-48e0-8fcb-5fef6d23739c/_apis/git/repositories/501a5e7e-ffdc-4d1e-a5e6-910f73c6eb9a/pullRequests/1506658/attachments/image.png)

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

#### PR Summary
This pull request fixes a bug by setting the default `whenMatched` option to `merge` instead of `replace` in the merge operation.
- Added tests in `bson_aggregation_stage_merge_tests.out` to verify the default `whenMatched` behavior.
- Updated shard key values in `bson_aggregation_stage_merge_tests.out` to reflect the new default behavior.
2024-11-12 18:48:09 +08:00
Jia Hu 778bc161e3 Merged PR 1452968: [schema validation] apply on general update
### 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)
yes
### Are you introducing any new config? If yes, do you have tests with and without them being set?

### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description
apply schema validation on general update

####Comments to follow:https://msdata.visualstudio.com/DefaultCollection/CosmosDB/_git/pgmongo/pullRequest/1452968#1729531108

----
#### AI description  (iteration 1)
#### PR Classification
New feature: Schema validation applied on general update operations.

#### PR Summary
This pull request introduces schema validation for update operations, ensuring documents comply with defined schemas during updates.
- Added `command_schema_validation_against_update` function and `ValidateSchemaOnDocumentUpdate` in `schema_validation.c` to handle schema validation during updates.
- Updated `bson_expr_eval.h` to include `ExprEvalState` struct definition.
- Modified `update.c` to integrate schema validation logic into batch and single document update processes.
- Enhanced `schema_validation_insert.sql` with tests for update operations involving schema validation.
2024-11-12 18:48:09 +08:00