Commit Graph
52 Commits
Author SHA1 Message Date
Vinod Sridharan 186cf63fcd Merged PR 1285018: [Range] Improve Range Filter Performance
### 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
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
N/A
### Description
Improve performance of $range opertor.

Two points:
1) Generalize support so queries like a = 1 AND b > 5 AND b < 6 can now use $range
2) We were sitll evaluating a runtime filter when we used $range. Remove the excess filter.
2024-03-01 17:24:28 +03:00
Vinod Sridharan a69e998708 Merged PR 1283564: [PG16] Move Mariner tests to PG16
### Does this PR have any customer impact?
No

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

### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
No
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description
Moves the Mariner tests to PG16 instead of PG15.
2024-03-01 17:24:28 +03:00
Vinod Sridharan d4018f7a46 Merged PR 1283033: [PG16] Part2: Enable backend tests for PG16
### 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)
No
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description
Changes:
- Unify rum_tuplesort_get_estimated_itemcount between PG16/PG15
- Remove set local force_parallel_mode TO ON; - This flag is removed in PG16
- Remove legacy query generation for lookup tests
- Citus 12.1 made the default behavior not to push down filters - set htat GUC to true for the extension
2024-03-01 17:24:28 +03:00
Tim Conley 04450d193d Merged PR 1280286: Add single batch for DataApi aggregates
### 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

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

### Description
2024-03-01 17:24:28 +03:00
Vinod Sridharan 0e156314f6 Merged PR 1282170: [PG16] Enable building the extension with PG16
### 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

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

### Description
Part 1: Enable building the extension and fix up pieces for building with PG16.

With this the core extension builds with PG16 and *most* of the backend tests pass. At this point, checking this in as a checkpoint (to ensure compat is retained) as more features are lit up with PG16

One thing to note is PG16 builds changes the default visibility of exports to 'private' that means that to make the current build work, we need to override that to 'default/public'. This needs to be fixed but is left as-is currently to make incremental progress.

There were some attempts to create exports in the code that are left as-is
2024-03-01 17:24:28 +03:00
Jayanta Mondal e916817aa6 Merged PR 1276499: [backend] Skipping optimizing with only $in
### 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)

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

### Description

single  fix
2024-03-01 17:24:28 +03:00
Vinod Sridharan 3b6e07f30f Merged PR 1281490: Query operator native support part 1: Enable expansion of the query 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 (OSS)

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

### Description
Today in OSS the query operator was evaluated at runtime - move this to expansion of hte operator at planning time using the simplify function.
2024-03-01 17:24:28 +03:00
Zinan Ren 🐾 27d920e43e Merged PR 1281181: [Vector Search] Support filter schema in 1.12-1
### 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)
UDF

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

### Description
To make preview feature "filter" works in 1.12 schema
2024-03-01 17:24:28 +03:00
Parag Jain 7bb916a093 Merged PR 1251259: Run backend test against citus 12 and removed existing change_stream with backward compat
This PR has following changes :
1.removed change_description column from mongo_data.document table because from citus 11.2 there was a [fix](https://github.com/citusdata/citus/commit/27e867afbc72180fb04b618293af5b3a944b6cd4) which results into [behavior mismatch in mongo_api_v1.collection function](https://msdata.visualstudio.com/CosmosDB/_workitems/edit/2942338). To handle this removed change_description column from mongo_data.document table.
2. modified backend pipeline to run backend test against citus 12 container image as well.
3. removed watch_collection and change_feed sql function as it is no longer needed in 1.13 binary.

subsequent PR :
Modify backend_test and deployment_build_pipeline  to run jstest and cSharpe test aginst citus 12.
Change Naming Convention of CosmosDbDrop and deployArtifact for citus-11 and citus-12

Related work items: #2902318, #2942338
2024-02-23 14:49:18 +03:00
Vinod Sridharan 37744ff32a Merged PR 1279725: [Flex] Enable Data plane metrics emission from the Extension
### Does this PR have any customer impact?
No

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

### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
No(ish)

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

### Description

Add function to emit data plane metrics from teh extension. Add a cron job to publish that every min.
Register that function as a cron job in flex.

This first part publishes the FeatureCounter data into warm path config as so:
![image.png](https://msdata.visualstudio.com/ba574a88-a171-48e0-8fcb-5fef6d23739c/_apis/git/repositories/501a5e7e-ffdc-4d1e-a5e6-910f73c6eb9a/pullRequests/1279725/attachments/image.png)

Subsequent changes will be made to add more metrics into the emission path.
2024-02-23 14:49:18 +03:00
Vinod Sridharan b3e28caf50 Merged PR 1280370: [Performance] Improve performance of point reads
### Does this PR have any customer impact?
Yes

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

### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
No

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

### Description
For point reads that go into the B-tree index, we were also evaluating the filter `docid @= { _id : value}` again even though those were equivalent.

Remove the extraneous filter to improve point read performance.
2024-02-23 14:49:18 +03:00
Mehmet Yilmaz 1224a287d6 Merged PR 1269280: [OSS] Move auth_scram functions to OSS
### 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

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

### Description
Move auth_scram functions to OSS
2024-02-23 14:49:18 +03:00
Ujjwal Agrawal 58ccf507d4 Merged PR 1235816: $centerSphere geospatial shape operator impl: Part 1 support for legacy coordinates and GeoJson points
As finalized in the design review on 10th January, `st_dwithin` shall be used for $center and $centerSphere
For index pushdown `st_dwithin` uses `st_expand` method to calculate the bounding box for given point, so we're using `st_expand` directly at the time of index pushdown, and `st_dwithin` at runtime.
This is part 1 of 2 that implements that change - this returns some false positives as st_dwithin returns true for polygons of which at least 1 point lies within the specified distance. It returns true even if all other points lie outside.
The next part will handle checking all points for distance in runtime.

**Brief summary of design discussion -**
$center used ST_BUFFER to create a buffer area, but using the same for geography has a few drawbacks -
1. If the buffer becomes bigger than a UTM zone or it crosses **the international dateline** it results in undefined behaviour. For example, the above query returns false if we increase the buffer radius to **12000000 (12000 km)** as it crosses the dateline at **(180 90)**.
Hence the query behavior looks like this -

```
[direct: mongos] db> db.geoquerytest.find({"a.b": {$geoWithin: {$centerSphere: [[0, 0], 1.57]}}})   //100013.6 km
[
  { _id: 1, a: { b: [ 10, 10 ] } },
  { _id: 2, a: { b: { long: Long("20"), lat: 20 } } },
  {
    _id: 3,
    a: [
      { b: { long: 25, lat: 25 } },
      [ 30, Decimal128("30") ],
      [ 35, 35 ]
    ]
  },
  { _id: 5, a: { b: { x: Long("12"), y: 12 } } }
]
[direct: mongos] db> db.geoquerytest.find({"a.b": {$geoWithin: {$centerSphere: [[0, 0], 1.6]}}})    //10205 km

```

2. The circle is **imperfect**. It has 8 segments in each quadrant (by default) which may result in boundary cases like below failing -

`SELECT ST_Covers(ST_BUFFER('Point(0 0)'::geography, 630000), 'Point(4.9757 2.66966)'::geography);` returns **false**.

Similar test on native mongo -
```
test> db.coll4.find({"a": {$geoWithin: {$centerSphere: [[0, 0], 0.0987]}}}) //629.5 km
[
  {
    _id: ObjectId("658304b574dc0e47e5cab903"),
    a: { type: 'Point', coordinates: [ 4.9757, 2.66966 ] }
  }
]
```

3. ST_Covers doesn't work well with polygons with holes. So this returns false -

```
SELECT ST_Covers(ST_BUFFER('Point(0 0)'::geography, 50000), 'MultiPolygon(((0.1 0.2, 0.1 0.3, 0.2 0.3, 0.2 0.2, 0.1 0.2), (0.15 0.22, 0.15 0.25, 0.18 0.25, 0.18 0.22, 0.15 0.22)))'::geography);
```

It was decided that ST_DWITHIN be used to overcome these limitations.

There's a bug in Explain behavior where it has a recheck condition even though recheck is set to false, it'll be tracked with this- https://msdata.visualstudio.com/CosmosDB/_workitems/edit/2968574

Related work items: #2903014, #2950457
2024-02-23 14:49:18 +03:00
Abhishek Johri 8bccdf75a9 Merged PR 1275797: Minor Bug Fix Current Op
### 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

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

### Description
String length for dropDatabase was wrong in Current Op
2024-02-23 14:49:18 +03:00
Vinod Sridharan bfa1cf4344 Merged PR 1275970: [Truncation] Implement top level object truncation
### Does this PR have any customer impact?
No(ish)

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

### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
No

### Release Note (Refer [Template](../docs/release_notes/template.md))
N/A

### Description
Implement truncation for documents + add testing.
Along with this fix a bug in array truncation.

Related work items: #2964175
2024-02-23 14:49:18 +03:00
Vinod Sridharan 3101112245 Merged PR 1262530: Helio API Gateway changes
### 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

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

### Description
Move Gateway to use the Helio_API schema for available top level methods.
2024-02-23 14:49:18 +03:00
Tanvi Bhandari cb3d803738 Merged PR 1274919: Cancel CreateIndex via DropIndex fails with Seg-fault
### 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

### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
Fix Segmentation Fault during dropping the long running create index request

### Description
**[Index Build Background] [During TIP in 1.13]**
Steps:
1. Trigger CreateIndex from one session
2. Trigger DropIndex for the same index from another session
3. It was causing Seg-fault because comment set by DropIndexes while marking index Skippable was empty.
4. Also, we should cancel the CREATE INDEX CONCURRENTLY before triggering DROP INDEX CONCURRENTLY

Related work items: #2961363
2024-02-16 13:49:10 +03:00
Jayanta Mondal 73b292ef9d Merged PR 1275225: [Testing] Changing test display name for better discovery
### Does this PR have any customer impact?
No
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Code Comment, Test Name change
### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
No
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description

For parameterized tests Azure devops only shows the custom display name of the tests and does not append the actual name of the test method. So, adding that in this PR, for better discoverability.

![image.png](https://msdata.visualstudio.com/ba574a88-a171-48e0-8fcb-5fef6d23739c/_apis/git/repositories/501a5e7e-ffdc-4d1e-a5e6-910f73c6eb9a/pullRequests/1275225/attachments/image.png)
2024-02-16 13:49:10 +03:00
Mehmet Yilmaz e329534b27 Merged PR 1265532: [OSS] Refactor some pgmongo references in OSS
### 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

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

### Description
Refactor some pgmongo references in OSS
2024-02-16 13:49:10 +03:00
Ayush Saluja 96408265a7 Merged PR 1248348: [pgmongo] $min $max projection stage operator
This is for supporting the $min, $max in the projection stage.

Related work items: #2954640
2024-02-16 13:49:10 +03:00
Jayanta Mondal 8016914aea Merged PR 1271425: $in query rewrite
### Does this PR have any customer impact?
Limited, the feature is behind a feature flag.

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

### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
No

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

### Description

Queries of the form

```
SELECT document FROM bson_aggregation_find('db', '{ "find": "in_opt_tests", "filter": { "accid":1, "vid": 1, "val": { "$in": [1, 3]} } }');
```

Will be **effectively** rewritten to

```
SELECT document FROM bson_aggregation_find('db', '{ "find": "in_opt_tests", "filter": { "accid":1, "vid": 1, "val": { "$in": [1, 3]} } }');

```

However, we don't intercept the mongo query and rewrite it. As the `$in` can be used in different query path. Instead, we do the rewrite after the query plan generation, and specifically, when `$in` is shows up a condition in the Index Path. While `$in` today is pushed down to the index, it's not performant.  However, if we rewrite the `$in` to be a `OR` of a set of `$eq` clause, that becomes peformant, as `RUM fast scan` is enabled for `$eq` but not yet for `$in`.  **For, 100K records, the latency goes down from `80ms` to ~`3ms` on devbox.**

**_Explain before rewrite:_**

```
               ->  Bitmap Index Scan on val_accid_vid  (cost=0.00..0.00 rows=1 width=0) (actual time=23.937..23.937 rows=7 loops=1)
                      Index Cond: Index Cond: ((document OPERATOR(mongo_catalog.@*=) '[{ "val" : { "$numberInt" : "1" } }, { "val" : { "$numberInt" : "3" } }]'::mongo_catalog.bson) AND (document OPERATOR(mongo_catalog.@=) '{ "accid" : { "$numberInt" : "1" } }'::mongo_catalog.bson) AND (document OPERATOR(mongo_catalog.@=) '{ "vid" : { "$numberInt" : "1" } }'::mongo_catalog.bson))*/

```

**_Explain after rewrite:_**
```

Custom Scan (Citus Adaptive)
   Task Count: 1
   Tasks Shown: All
   ->  Task
         Node: host=localhost port=58080 dbname=regression
         ->  Bitmap Heap Scan on documents_33000_330023 collection
               Recheck Cond: (((document OPERATOR(mongo_catalog.@=) '{ "val" : { "$numberInt" : "1" } }'::mongo_catalog.bson) AND (document OPERATOR(mongo_catalog.@=) '{ "accid" : { "$numberInt" : "1" } }'::mongo_catalog.bson) AND (document OPERATOR(mongo_catalog.@=) '{ "vid" : { "$numberInt" : "1" } }'::mongo_catalog.bson)) OR ((document OPERATOR(mongo_catalog.@=) '{ "val" : { "$numberInt" : "3" } }'::mongo_catalog.bson) AND (document OPERATOR(mongo_catalog.@=) '{ "accid" : { "$numberInt" : "1" } }'::mongo_catalog.bson) AND (document OPERATOR(mongo_catalog.@=) '{ "vid" : { "$numberInt" : "1" } }'::mongo_catalog.bson)))
               Filter: ((document OPERATOR(mongo_catalog.@*=) '{ "val" : [ { "$numberInt" : "1" }, { "$numberInt" : "3" } ] }'::mongo_catalog.bson) AND (shard_key_value = '4322365043291501017'::bigint))
               ->  BitmapOr
                     ->  Bitmap Index Scan on val_accid_vid
       ...
2024-02-16 13:49:10 +03:00
Ayush Saluja 075acbf3a0 Merged PR 1267038: [pgmongo]Aggregation Operator BinarySize
### Does this PR have any customer impact?
Yes, Support for new

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

### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
No

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

### Description
Adding support for  $binarySize operator in data size.
https://www.mongodb.com/docs/manual/reference/operator/aggregation/binarySize/

Related work items: #2019187
2024-02-16 13:49:10 +03:00
Deepak Bisht bf9ef6e59e Merged PR 1247537: [Pgmong][Geospatial] - 2d segmentize takes a huge time for large query boxes.
So in the earlier PR to segmentize the given geography query with 500km of segment length we were deriving the segment length for 2d using this strategy:

1- 2d distance of (0,0 to 1,1) => 1.41
2- 2dsphere distance of (0, 0 to 1, 1) =>156.9Km

So the segment length for 2d becomes => ( 500 ) / (157/1.41) -> ~4.41

But this is only true if the 2d bounds are similar to earth coordinates and will start taking time when query boxes are bigger than earth bounds.

So in this PR I approximately scale up the segment length based on the size of the 2d region. So that segmentize should work relative to the given size

Related work items: #2894618
2024-02-14 11:28:20 +03:00
Vinod Sridharan 44678d8185 Merged PR 1272971: [Explain] More Explain Improvements based on investigations & TTL Flag
### Does this PR have any customer impact?
No

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

### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
No

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

### Description
Add option for BUFFERS & TIMING on the explain.
Also add RowsRemovedByIndexRecheck and RowsRemovedByFilter as top level.

For TTL, always set forceUseIndexIfAvailable
2024-02-14 11:28:20 +03:00
Vinod Sridharan d57e9aa236 Merged PR 1271766: Improve performance of the $lt operator
### Does this PR have any customer impact?
Yes
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Perf
### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
No
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
Improve $lt performance when having mixed types
### Description
In scenarios where $lt was applied to a field that had "nulls" in it, we would start with MinKey and scan up - which would require passing through all the null valued entries.

Do a best effort to pick a lower bound that is better than MinKey when available.
2024-02-14 11:28:20 +03:00
Vinod Sridharan 21db4c0aa3 Merged PR 1270439: Remove excess shared preload libraries
### 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

### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
None
### Description
Remove excess shared_preload_libraries from various configurations.
2024-02-14 11:28:20 +03:00
Vinod Sridharan 6c8bf4f145 Merged PR 1268933: Enable Primary key lookup pushdown
### Does this PR have any customer impact?
Yes
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Performance
### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
No
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
Push primary key lookup where available
### Description
Due to RUM index limitations today we would push to the rum index even if we are matching a single doc or a few docs. Ensure that we have a primary key lookup if we see an explicit lookup there

Primary key lookup
2024-02-07 23:20:07 +03:00
Tanvi Bhandari b9d48d0f37 Merged PR 1267753: Fix for stale index entry in PG
### 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

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

### Description

**Issue**
During testing in westus3 (TIP), we have observed that sometimes for long running create index, if user tries to cancel it by running `dropIndexes` concurrently, then sometimes `DROP INDEX CONCURRENTLY` causes BE server failure then this results in following things:
1. Index request is removed in `pgmongo_index_request` table
2. Index is not really dropped from the system and marked INVALID by Postgres.
3. The index metadata in `collection_indexes` also exists (invalid state).
4. In short, this leaves the system with stale index metadata + invalid index entry.
5. Since `index_build_is_in_progress` considers Skippable index, the `getIndexes()` and `CheckIndexSpecConflictWithExistingIndexes` will return the index entry

**Symptom**
1. `getIndexes` API will return index entry.
2. User will not be able to recreate the index with same definition because of `CheckIndexSpecConflictWithExistingIndexes`
3. The index is marked INVALID as per `postgres`.
4. Queries will not be able to use the index which is fine because user anyways wanted to cancel the index creation in first place.
5. Index metadata also contains the index entry (is_valid = false)

**Mitigation**
1. User can explicitly call DropIndex(<index-name>) API to fix the state of system.

**Solution**
1. Delete CreateIndex request from queue via `CleanupIndexBuildRequest` once everything is done in `dropIndexes`.
2. Make sure that we do not return indexes which are marked Skippable in `index_build_is_in_progress`

This will result in following things:
1. `getIndexes` API will not return the skippable entry
2. User will be able to recreate the index with same definition
3. The Cron-job will delete everything about this Skippable index request from system after 20 mins (aka IndexQueueEvictionIntervalInSec)
2024-02-07 23:20:07 +03:00
Mehmet Yilmaz cb797d3eae Merged PR 1261782: [OSS] Move drop_database function to OSS
### 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)
UDF

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

### Description
Move drop_database function to OSS
2024-02-07 23:20:07 +03:00
Zinan Ren 🐾 69118d324f Merged PR 1246367: [Vector Search] Support pre-filtering in search - Part 2
### Known limitations & TODO for part 2
- [ ]  The current implementation intersects results from both vector index and bitmap index, it is actually the post-filtering
- [ ]  Not work for sharded collection

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

### New explain result
![image (5).png](https://msdata.visualstudio.com/ba574a88-a171-48e0-8fcb-5fef6d23739c/_apis/git/repositories/501a5e7e-ffdc-4d1e-a5e6-910f73c6eb9a/pullRequests/1246367/attachments/image%20%285%29.png)
From mongo command:
```
SELECT document FROM
    bson_aggregation_pipeline('db', '
        {
        "aggregate": "aggregation_pipeline_ivf_filter",
        "pipeline": [
                {
                "$search": {"cosmosSearch": { "vector": [ 3.0, 4.9, 1.0 ], "k": 4, "path": "v", "filter": { "a": "some sentence" }, "nProbes": 1 }  }
                }
        ],
        "cursor": {}
}');

```
To psql command
```
1. SELECT c1(search query):
			SELECT
				document,
				(public.vector(mongo_catalog.bson_extract_vector(collection.document, 'v'::text), 3, true) OPERATOR(public.<=>) public.vector(mongo_catalog.bson_extract_vector('{ "vector" : [ { "$numberDouble" : "3.0" }, { "$numberDouble" : "4.9000000000000003553" }, { "$numberDouble" : "1.0" } ], "k" : { "$numberInt" : "1" }, "path" : "v" }'::mongo_catalog.bson, 'vector'::text), 3, true)) AS orderVal,
				ctid
			FROM
				mongo_data.documents_1 collection
			WHERE
				shard_key_value = 0
				AND ((mongo_catalog.bson_extract_vector(collection.document, 'v'::text) IS NOT NULL))
			ORDER BY
				(public.vector(mongo_catalog.bson_extract_vector(collection.document, 'v'::text), 3, true) OPERATOR(public.<=>) public.vector(mongo_catalog.bson_extract_vector('{ "vector" : [ { "$numberDouble" : "3.0" }, { "$numberDouble" : "4.9000000000000003553" }, { "$numberDouble" : "1.0" } ], "k" : { "$numberInt" : "1" }, "path" : "v" }'::mongo_catalog.bson, 'vector'::text), 3, true))
2. SELECT c2(filter query):
			SELECT
				ctid
			FROM
				mongo_data.documents_1
			WHERE
				shard_key_value = 0
				AND document @@ '{ "a": "some sentence" }'

3. JOIN c1 ON c1.ctid = c2.ctid
			SELECT
				c1.document
			FROM c1 JOIN c2 ON c2.ctid = c1.ctid
			ORDER BY c1.orderVal
			LIMIT 1
```

Related work items: #2586299
2024-02-07 23:20:07 +03:00
Mehmet Yilmaz 48e0ca3d05 Merged PR 1255683: Refactor geospatial func name in oss
Refactor geospatial func name in oss
2024-02-07 23:20:07 +03:00
Vinod Sridharan da2c098f3c Merged PR 1265302: Make sh.status() work
### 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)
No

### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
Make sh.status() work in mongo shell.

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

With these changes, this now looks like:
![image (2).png](https://msdata.visualstudio.com/ba574a88-a171-48e0-8fcb-5fef6d23739c/_apis/git/repositories/501a5e7e-ffdc-4d1e-a5e6-910f73c6eb9a/pullRequests/1265302/attachments/image%20%282%29.png)
2024-02-07 23:20:07 +03:00
Lucas Borges Fernandes a4f49d76af Merged PR 1263501: Querying PG authenticated user for LibPQ connections
### Description

A bug was found while trying to create indexes on top of Meru. We internally create a new Postgres connection using the LibPQ API without providing the username, causing permission issues. This PR fixes this.
2024-02-07 23:20:07 +03:00
Tanvi Bhandari e5be945fef Merged PR 1265017: Merged PR 1264390: To enable feature in 1.12 and main release as well
### 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
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
NA
### Description

1.  !1264390 PR merged
2. Delete the old queue table in upgrade path from all nodes
3. Add the upgrade scenario 1.12 -> latest in BE test
2024-02-07 23:20:07 +03:00
Tanvi Bhandari 08365f523c Merged PR 1262739: To enable feature in 1.12 and main release as well
### 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

### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
To enable IndexBuild Background in 1.12

### Description
To enable IndexBuild Background in 1.12 on old schema and new schema as well based on cluster version.
2024-02-07 23:20:07 +03:00
Vinod Sridharan 3775e5a27a Merged PR 1263670: Add more checks for OSS 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)

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

### Description

Add more checks for OSS references
2024-02-07 23:20:07 +03:00
Santiago Fernandez Madero b063424b6d Merged PR 1263734: Fix segfault in insert by setting the right param list size
Fix segfault in insert by setting the right param list size.

Since we're allocating more space to be on the safe size and overrun memory, we need to set the paramList size to the actual batch size to avoid getting garbage memory and been prone to seg fault.
2024-02-07 23:20:07 +03:00
Vinod Sridharan b411fc3944 Merged PR 1262518: Remove extra feature flag for Index truncation
### 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)
No

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

### Description
Index truncation had 2 levels of flags (one a GUC, and another is an index option).
Leave behind the index option and remove the GUC (Customers can opt-in using this undocumented flag).
2024-02-07 23:20:07 +03:00
Vinod Sridharan 6c22592a58 Merged PR 1261022: Fix up memory leaks on compare
### Does this PR have any customer impact?
No? Or makes it better

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

### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
No

### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
Fix up memory leaks in sort, group, create index

### Description
Fix up memory leaks on compare: for TOAST tuples, or compressed tuples, we would decompress or load tuples in memory. These weren't freed in the case where we were in the tuple sort contexts.
2024-02-07 23:20:07 +03:00
Mehmet Yilmaz 73cf79a3ca Merged PR 1258267: Refactor bson aggregation pipeline test in OSS
### 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

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

### Description
Refactoring schema name in the bson aggregation pipeline test in OSS
2024-01-31 12:06:30 +03:00
Tanvi Bhandari b1d31514b2 Merged PR 1244012: Misc changes 'mongo_catalog.pgmongo_index_queue'
1. Make index queue table name compatible to oss i.e its name should be helio_api_catalog.helio_index_queue and grant permission for helio_admin_role

2. Add citus_add_local_table_to_metadata('helio_api_catalog.helio_index_queue')

3. Due to extension upgrade scripts, the table was created on all nodes of cluster. Therefore, dropped the table from all nodes.
And create it only on coordinator using initialize_cluster(for new cluster) and complete_pgmongo_upgrade (for upgrade path)

4. Simplify CleanUpIndexBuildRequest query

Related work items: #2897026
2024-01-31 12:06:30 +03:00
Vinod Sridharan 45608162fd Merged PR 1256608: [Truncation] Disable Truncation on all wildcard indexes, text and hash indexes
Disable Truncation on all wildcard indexes, text and hash indexes
2024-01-31 12:06:30 +03:00
Mehmet Yilmaz dc0f79ce70 Merged PR 1234831: [OSS] Move drop indexes procedure to OSS
Move drop indexes procedure to oss
2024-01-31 12:06:30 +03:00
Vinod Sridharan 1ca13d07e5 Merged PR 1253069: [Truncation] Fix up a bug with single path wildcard index with truncation
Fix up a bug with single path wildcard index with truncation
2024-01-31 12:06:30 +03:00
Vinod Sridharan 03c69f703d Merged PR 1249283: [Index Truncation] Add more tests and allow per index registration of truncation
1) Enable per index enablement of truncation
2) Add more tests for aarray truncation
3) Reduce prefix paths for single path indexes
2024-01-19 14:59:12 +03:00
Vinod Sridharan 628c576d6f Merged PR 1250361: Modify more references for OSS
Remove more references  in code that match the contract with the OSS extension.
2024-01-17 22:08:45 +03:00
Santiago Fernandez Madero d6b2c3aab4 Merged PR 1248408: [OSS] Fix listIndexes and listCollections command
List indexes was broken in OSS:
- when generating the backend query we were using the api.list_indexes SQL UDF which is the former/old way before cursors support to list indexes and it is available in pgmongo, but since that is obsolete and don't support cursors, we didn't added it to OSS.

Fix is to instead generate a query that fetches directly from the `helio_api_catalog.collection_indexes` table which is basically what list_indexes did:

```
SELECT mongo_api_internal.index_spec_as_bson(index_spec, TRUE)
        FROM mongo_catalog.collection_indexes
        WHERE collection_id = v_collection.collection_id AND
              (index_is_valid OR mongo_api_internal.index_build_is_in_progress(index_id))
        ORDER BY index_id
```
List Collections was broken in OSS because we were using the wrong schema to get the `row_get_bson` UDF and the OpExpr for the text equality for the query where clause `database = <dbName>` , we were not specifying a collation and postgres was failing with:

```
ERROR:  could not determine which collation to use for string comparison
HINT:  Use the COLLATE clause to set the collation explicitly.
```
2024-01-17 22:08:45 +03:00
Lucas Borges Fernandes 9839f0610e Merged PR 1249793: Changing extension name to helio in all OSS files
Removing references from the old extension name.
2024-01-17 22:08:45 +03:00
Tanvi Bhandari e56a5f6edb Merged PR 1216978: Add Index details in CurrentOp for CREATE INDEX
This PR is on top of !1215017 , I will keep both changes in separate PRs.

Does following for non-unique indexes CREATE INDEX .
1. Add DB name, collection name in currentOp
2. Add Index details in CurrentOp

NOTE: For Unique index (ALTER TABLE), current op does have collection name populated. We are not adding index details for unique index as of now. Tracking item #2843068

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

Related work items: #2826862, #2835383
2024-01-17 22:08:45 +03:00
Deepak Bisht cd6050eb08 Merged PR 1245028: [pgmongo][Geospatial] - enable Geospatial for Tests
enable Geospatial for Tests

Related work items: #2889615
2024-01-17 22:08:45 +03:00