Commit Graph

42 Commits

Author SHA1 Message Date
Catalin Sumanaru
224f399581 SERVER-89828 Explicitly pass the db object to query_settings_index_hi… (#21493)
GitOrigin-RevId: 881d023c82f71cb6487c0088e3e28d2c3af9238c
2024-05-02 09:26:32 +00:00
Mindaugas Malinauskas
4f3dee0c00 SERVER-89118 Make 'setQuerySettings' and 'removeQuerySettings' commands to correctly perform concurrency control (#21270)
GitOrigin-RevId: 74bb6bb329800d4369f2b4fdc2765962482e2dc9
2024-04-24 09:56:13 +00:00
Catalin Sumanaru
e44e12a29b SERVER-89552 Improve debuggability of query_settings_server_status.js (#21249)
GitOrigin-RevId: eb26a2f440f5648c00bc3f7e5e21cafc92364933
2024-04-19 11:14:47 +00:00
romanskas
f1fe561ff4 SERVER-87345 Replace one large query with few smaller queries in test (#20962)
Previous version of the test relied on a single extremely large query
(close to 16MB). Unfortunately, extremely large queries have their own
problems, which are not related to query settings

GitOrigin-RevId: 597c0b62073e92236ddaccf2460d408ed6c49b1e
2024-04-12 21:59:05 +00:00
Catalin Sumanaru
032d4ba007 SERVER-88333 Introduce query settings fallback suite (#20429)
GitOrigin-RevId: da4b8fa0d6f0ef55d94eac1cccc9f2413cee4fbb
2024-04-12 17:29:35 +00:00
Denis Grebennicov
653c63c52d SERVER-81556 Refactor QuerySettings.indexHints idl definition to always be std::vector<IndexHintSpec> (#20985)
GitOrigin-RevId: 638911b54c0cbab7acc20dfdd9482ef091cadc08
2024-04-12 08:57:05 +00:00
Denis Grebennicov
8b84cef627 SERVER-87031 Ensure query settings query framework knob overrides query knob values (#20470)
GitOrigin-RevId: cc645255f9a76da6385b7466057bbe0b6d244138
2024-03-29 13:05:25 +00:00
Serhii Lysenko
55fc199b9f SERVER-86418 Add QueryShapeHash to $currentOp (#19962)
GitOrigin-RevId: 45324801a0064c39cb5885bdf95deda8f878b380
2024-03-26 12:58:30 +00:00
romanskas
b9390ecd9e SERVER-86489 Do not apply query settings to queries with encryption information (#19894)
Persistent query settings should not apply to queries with encryption
information to minimize possible attack space:
- unintentionally exposing encrypted attribute values, types or
cardinality
- using persistent query settings to guess the shapes of encrypted
queries

GitOrigin-RevId: 294116f3e3ef85bfa7b4fd66df7469104a92e1d4
2024-03-20 16:14:02 +00:00
Catalin Sumanaru
dd1570944d SERVER-86174 Avoid unnecessary fillOutPlannerParams() and fillOutSecondaryCollectionsInformation() calls (#19635)
GitOrigin-RevId: 7a26f4d544e4a670a25c598e34d5912d8ba7d52e
2024-03-12 10:31:10 +00:00
romanskas
68eb5e43e5 SERVER-87585 Make removeQuerySettings retryable (#19802)
Until this change 'removeQuerySettings' would throw when the setting is
not found. With this behaviour 'removeQuerySettings' cannot be re-tried,
which causes problems in test infrastructure. Therefore we have decided
not to throw when the settings was not found.

GitOrigin-RevId: fd2ff323d5831eedeb130609097d4fbdc49d238e
2024-03-12 03:53:05 +00:00
romanskas
f5bc2f40d6 SERVER-86491 Allow to set query settings via hash (#19335)
When slow queries are printed into the log they can be truncated and
therefore cannot be used in the 'setQuerySettings' command. To avoid
this we allow adding new query settings only by hash without a
representative query.

GitOrigin-RevId: 18f4c9edbc7f04ea10d02eeca5781094174995b0
2024-03-07 01:56:41 +00:00
Denis Grebennicov
c842c976cb SERVER-79231 Apply QuerySettings for aggregate commands with $lookup (#17681)
SERVER-79231 Apply QuerySettings for aggregate commands with $lookup
This patch ensures that query settings are applied on aggregate
commands, including the commands that contain $lookup stages.
QueryPlannerParams::fillOutSecondaryCollectionsPlannerParams() is marked
as private, such that clients can only call fillOutPlannerParams() in
order to populate the QueryPlannerParams.
GitOrigin-RevId: e22a78c7fc5f9c16ce4989179b635c9065932581
2024-02-24 23:16:20 +00:00
Daniel Segel
4d003935ae SERVER-83994 Add tests to confirm persistent query settings override trySbeRestricted (#18971)
GitOrigin-RevId: f3084a811a9b778e674272550490252173f74994
2024-02-22 00:24:31 +00:00
James H
51918558f3 SERVER-85876: Reject requests matching QuerySettings with reject=true (#18645)
SERVER-85876
Reject requests matching QuerySettings with reject=true

If an admin has set reject in QuerySettings matching an incoming
find/agg/distinct, the request should be failed.

However, explaining such a query is comparatively cheap and is useful
as a debugging tool. As such, explains for such queries should still be
permitted.

GitOrigin-RevId: ca54838c041844066760e2dadf682e6a05679260
2024-02-20 09:33:06 +00:00
James H
9a194bd557 SERVER-85874: Add reject flag in QuerySettings (#18606)
GitOrigin-RevId: eb7caaa39db3e0bc9cb1f7668fd3180e0789077a
2024-02-14 12:22:50 +00:00
serhiitea
83e9e01244 SERVER-85214 Fallback to multiplaning when query settings application failed (#18521)
GitOrigin-RevId: 6b3f73b432980417af0f88e09de0c1772f06dbe3
2024-02-08 20:07:35 +00:00
Catalin Sumanaru
98338e7fc0 SERVER-79233 Ensure query settings $natural hints are applied for the specified queries (#18230)
GitOrigin-RevId: e9d44fda572a9eeeb547d7df8b9328e9ae7714cc
2024-01-23 15:38:23 +00:00
auto-revert-processor
1bd6850c53 Revert "SERVER-79233 Ensure query settings $natural hints are applied for the specified queries (#17197)"
This reverts commit 7e405b23fa7af7b2112815b479ccbcf0daa3539e.

GitOrigin-RevId: 05786ddb21554e894c31e6769678cd6847a149fe
2024-01-22 17:26:50 +00:00
Catalin Sumanaru
0376d0cbc2 SERVER-79233 Ensure query settings $natural hints are applied for the specified queries (#17197)
GitOrigin-RevId: 7e405b23fa7af7b2112815b479ccbcf0daa3539e
2024-01-22 11:17:35 +00:00
Catalin Sumanaru
5b57e0c3ec SERVER-84047 Introduce cursor_hints_to_query_settings test suite (#17534)
GitOrigin-RevId: 9d793e0bc1498580a1e65764da9786d4e01e24fb
2024-01-08 15:18:03 +00:00
Denis Grebennicov
ace6336b5b SERVER-77080 Introduce query settings into explain output for aggregation
This patch makes sure that corresponding query settings appear in the
explain of the aggregate commands, if those commands have query settings
set. This includes adding 'querySettings' to the aggregate command idl
as well as propagating the query settings from mongos to the shards in
sharded cluster deployment.

GitOrigin-RevId: 9ad100fc9ecb2053db6e07950bd988a0deef1180
2023-12-13 21:02:31 +00:00
Serhii Lysenko
b3e956f1b3 SERVER-79105: Support distinct command in setQuerySetting() / removeQuerySettings()
Implement conversion from raw command BSON to RepresentativeQueryInfo for distinct.
2023-12-01 19:30:45 +00:00
Romans Kasperovics
5fa345a76a SERVER-81062 Update cluster parameter cache before and after modifications
Cluster parameter values are cached on routers = mongoS and updated (pulled)
from the config-servers periodically by the 'ClusterServerParameterRefresher'
background job. This means, the new cluster parameter value will not be cached
immediately, but after some delay. This delay is problematic for the
'querySettings' cluster parameter which has read-modify-write updates, because
subsequent 'setQuerySettings' or 'removeQuerySettings' commands might have
a non-deterministic outcome. This change minimizes the delay by forcing
'ClusterServerParameterRefresher' iterations before and after the modification.
2023-11-17 14:15:56 +00:00
Denis Grebennicov
99d4911e13 SERVER-77469 Propagate QuerySettings from mongos to the shards
Before this change, query settings were only looked up on mongod, which means that query settings will not be applied to find queries that were modified on mongos. In order to fix this issue, query settings will be looked up on mongos in sharded cluster and on mongod in replica set deployments. Upon the lookup, query settings will be propagated to the shards as command's new 'querySettings' attribute (marked as unstable).

In addition, as a part of this change, the encoding of a CanonicalQuery into a QueryShapeString will omit the 'hint' field if it is made redundant by the matching query setting.
2023-11-15 10:45:37 +00:00
auto-revert-processor
71e55df5b3 Revert "SERVER-77469 Propagate QuerySettings from mongos to the shards"
This reverts commit 98d757f948.
2023-11-13 22:09:04 +00:00
Denis Grebennicov
98d757f948 SERVER-77469 Propagate QuerySettings from mongos to the shards
Before this change, query settings were only looked up on mongod, which means that query settings will not be applied to find queries that were modified on mongos. In order to fix this issue, query settings will be looked up on mongos in sharded cluster and on mongod in replica set deployments. Upon the lookup, query settings will be propagated to the shards as command's new 'querySettings' attribute (marked as unstable).

In addition, as a part of this change, the encoding of a CanonicalQuery into a QueryShapeString will omit the 'hint' field if it is made redundant by the matching query setting.
2023-11-13 14:13:26 +00:00
auto-revert-processor
d55c78bd72 Revert "SERVER-77469 Propagate QuerySettings from mongos to the shards"
This reverts commit 39dd12e256.
2023-11-11 02:26:11 +00:00
Denis Grebennicov
39dd12e256 SERVER-77469 Propagate QuerySettings from mongos to the shards
Before this change, query settings were only looked up on mongod, which means that query settings will not be applied to find queries that were modified on mongos. In order to fix this issue, query settings will be looked up on mongos in sharded cluster and on mongod in replica set deployments. Upon the lookup, query settings will be propagated to the shards as command's new 'querySettings' attribute (marked as unstable).

In addition, as a part of this change, the encoding of a CanonicalQuery into a QueryShapeString will omit the 'hint' field if it is made redundant by the matching query setting.
2023-11-10 21:10:15 +00:00
Denis Grebennicov
c9480ade7e SERVER-82432 Adjust the 'clusterServerParameterRefreshIntervalSecs' in query settings related tests to avoid suite timeouts 2023-10-26 17:02:45 +00:00
auto-revert-processor
36b6290197 Revert "SERVER-82432 Adjust the 'clusterServerParameterRefreshIntervalSecs' in query settings related tests to avoid suite timeouts"
This reverts commit 3568a06ccf.
2023-10-26 00:20:39 +00:00
Denis Grebennicov
3568a06ccf SERVER-82432 Adjust the 'clusterServerParameterRefreshIntervalSecs' in query settings related tests to avoid suite timeouts 2023-10-25 13:44:34 +00:00
csum112
8ba7843f1e SERVER-77790 Add support for showDebugQueryShape parameter in $querySettings 2023-10-18 09:26:00 +00:00
Denis Grebennicov
cef68707ee SERVER-79181 Apply QuerySettings for find commands 2023-10-16 08:06:56 +00:00
auto-revert-processor
17171f3aa0 Revert "SERVER-77790 Add support for showDebugQueryShape parameter in $querySettings"
This reverts commit ff430ce9d2.
2023-10-14 04:04:58 +00:00
csum112
ff430ce9d2 SERVER-77790 Add support for showDebugQueryShape parameter in $querySettings 2023-10-13 16:15:57 +00:00
csum112
20c19e25ef SERVER-79227: Introduce ServerStatusMetrics for query settings 2023-09-11 09:23:25 +00:00
Denis Grebennicov
5cb5ddb93d SERVER-80597 Ensure query settings are present on mongos before removing them in query_settings_cmds_validation.js 2023-09-04 08:13:08 +00:00
auto-revert-processor
4f1fbb25f7 Revert "SERVER-80597 Ensure query settings are present on mongos before removing them in query_settings_cmds_validation.js"
This reverts commit 430ad34747.
2023-09-02 06:56:11 +00:00
Denis Grebennicov
430ad34747 SERVER-80597 Ensure query settings are present on mongos before removing them in query_settings_cmds_validation.js
Due to timing issue it may happen that `removeAllQuerySettings()` doesn't remove
"all" query settings, because at the moment of deletion, not all of them are
present on mongos.

This patch resolves this issue, by asserting that the newly inserted query
settings are present on mongos as well as ensuring that the query settings are
no longer present upon deletion.
2023-09-01 22:43:30 +00:00
Denis Grebennicov
847fa22207 SERVER-77079 Introduce query settings into explain output for find
'querySettings' field is added to the explain output.
QueryShapeHash is lazily computed on QuerySettings lookup. The hash is computed
only in cases when there is at least on query settings set for a given tenant.
2023-09-01 14:12:36 +00:00
Romans Kasperovics
0822d6df96 SERVER-78802 Reject concurrent setQuerySettings on replica sets
Until now, a new value of a cluster parameter was just replacing the old one.
For the query settings project it is important to read / modify / write
cluster parameter values. In this scenario, concurrent calls of
'setQuerySettings' command may lead to seemingly successful, but incorrect
results.
This change introduces an additional 'previousTime' parameter to ensure
that the cluster parameter value that was read has not changed at the time
of writing, otherwise the operation must fail.
2023-08-30 09:45:12 +00:00