Skip to content

Commit fa404d4

Browse files
GitSparTVsegoon
authored andcommitted
feat mongo: remove MONGO_DEADLINE_PROPAGATION_ENABLED_V2
Vibe-coded at Zero Cost Conf 😎 Fixes: #449 Tests: протестировано CI Pull Request resolved: #984 commit_hash:fce5760d66742781716a7420c10f19f90bb47989
1 parent 2a6a7dc commit fa404d4

File tree

11 files changed

+44
-38
lines changed

11 files changed

+44
-38
lines changed

.mapping.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2715,8 +2715,8 @@
27152715
"mongo/dynamic_configs/MONGO_CONGESTION_CONTROL_ENABLED.yaml":"taxi/uservices/userver/mongo/dynamic_configs/MONGO_CONGESTION_CONTROL_ENABLED.yaml",
27162716
"mongo/dynamic_configs/MONGO_CONGESTION_CONTROL_SETTINGS.yaml":"taxi/uservices/userver/mongo/dynamic_configs/MONGO_CONGESTION_CONTROL_SETTINGS.yaml",
27172717
"mongo/dynamic_configs/MONGO_CONNECTION_POOL_SETTINGS.yaml":"taxi/uservices/userver/mongo/dynamic_configs/MONGO_CONNECTION_POOL_SETTINGS.yaml",
2718-
"mongo/dynamic_configs/MONGO_DEADLINE_PROPAGATION_ENABLED_V2.yaml":"taxi/uservices/userver/mongo/dynamic_configs/MONGO_DEADLINE_PROPAGATION_ENABLED_V2.yaml",
27192718
"mongo/dynamic_configs/MONGO_DEFAULT_MAX_TIME_MS.yaml":"taxi/uservices/userver/mongo/dynamic_configs/MONGO_DEFAULT_MAX_TIME_MS.yaml",
2719+
"mongo/dynamic_configs/USERVER_DEADLINE_PROPAGATION_ENABLED.yaml":"taxi/uservices/userver/mongo/dynamic_configs/USERVER_DEADLINE_PROPAGATION_ENABLED.yaml",
27202720
"mongo/functional_tests/CMakeLists.txt":"taxi/uservices/userver/mongo/functional_tests/CMakeLists.txt",
27212721
"mongo/functional_tests/basic_chaos/CMakeLists.txt":"taxi/uservices/userver/mongo/functional_tests/basic_chaos/CMakeLists.txt",
27222722
"mongo/functional_tests/basic_chaos/mongo_service.cpp":"taxi/uservices/userver/mongo/functional_tests/basic_chaos/mongo_service.cpp",

mongo/dynamic_configs/MONGO_DEADLINE_PROPAGATION_ENABLED_V2.yaml

Lines changed: 0 additions & 6 deletions
This file was deleted.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
default: true
2+
description: |
3+
When `false`, disables deadline propagation in the service. This includes:
4+
5+
- reading the task-inherited deadline from HTTP headers and gRPC metadata;
6+
- interrupting operations when deadline expires;
7+
- propagating the deadline to downstream services and databases.
8+
9+
Deadline propagation can also be disabled in the static config of:
10+
- components::Server (disables the HTTP handler part).
11+
12+
Deadline propagation is disabled if disabled statically OR dynamically.
13+
schema:
14+
type: boolean

mongo/functional_tests/basic_chaos/tests-deadline-propagation/test_deadline_propagation.py

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ async def _put_foo_value(service_client):
1414

1515

1616
async def test_works(service_client, put_foo_value, dynamic_config):
17-
assert dynamic_config.get('MONGO_DEADLINE_PROPAGATION_ENABLED_V2')
17+
assert dynamic_config.get('USERVER_DEADLINE_PROPAGATION_ENABLED')
1818

1919
async with service_client.capture_logs() as capture:
2020
response = await service_client.get(
@@ -29,20 +29,3 @@ async def test_works(service_client, put_foo_value, dynamic_config):
2929
text = logs[0]['text']
3030
assert 'Operation cancelled: deadline propagation' in text, text
3131
assert 'storages::mongo::CancelledException' in text, text
32-
33-
34-
@pytest.mark.config(MONGO_DEADLINE_PROPAGATION_ENABLED_V2=False)
35-
async def test_disabled(service_client, put_foo_value, dynamic_config):
36-
async with service_client.capture_logs() as capture:
37-
response = await service_client.get(
38-
'/v1/key-value?key=foo&sleep_ms=200',
39-
headers={DP_TIMEOUT_MS: '100'},
40-
)
41-
assert response.status == 498
42-
assert response.text == 'Deadline expired'
43-
44-
# The mongo request should be completed ignoring the fact that
45-
# deadline has already expired.
46-
logs = capture.select(_type='response', meta_type='/v1/key-value')
47-
assert len(logs) == 1, logs
48-
assert logs[0].get('dp_original_body', None) == 'bar', str(logs)

mongo/library.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ configs:
1414
- MONGO_CONGESTION_CONTROL_ENABLED
1515
- MONGO_CONGESTION_CONTROL_SETTINGS
1616
- MONGO_CONNECTION_POOL_SETTINGS
17-
- MONGO_DEADLINE_PROPAGATION_ENABLED_V2
17+
- USERVER_DEADLINE_PROPAGATION_ENABLED
1818
- MONGO_DEFAULT_MAX_TIME_MS

mongo/src/storages/mongo/cdriver/collection_impl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
#include <storages/mongo/operations_common.hpp>
2323
#include <storages/mongo/operations_impl.hpp>
2424

25-
#include <dynamic_config/variables/MONGO_DEADLINE_PROPAGATION_ENABLED_V2.hpp>
2625
#include <dynamic_config/variables/MONGO_DEFAULT_MAX_TIME_MS.hpp>
26+
#include <dynamic_config/variables/USERVER_DEADLINE_PROPAGATION_ENABLED.hpp>
2727

2828
USERVER_NAMESPACE_BEGIN
2929

@@ -105,7 +105,7 @@ impl::cdriver::FindAndModifyOptsPtr CopyFindAndModifyOptions(const impl::cdriver
105105
}
106106

107107
std::optional<std::chrono::milliseconds> GetDeadlineTimeLeft(const dynamic_config::Snapshot& config) {
108-
if (!config[::dynamic_config::MONGO_DEADLINE_PROPAGATION_ENABLED_V2]) return std::nullopt;
108+
if (!config[::dynamic_config::USERVER_DEADLINE_PROPAGATION_ENABLED]) return std::nullopt;
109109

110110
const auto inherited_deadline = server::request::GetTaskInheritedDeadline();
111111
if (!inherited_deadline.IsReachable()) return std::nullopt;

mongo/src/storages/mongo/cdriver/pool_impl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#include <userver/storages/mongo/exception.hpp>
2626
#include <userver/storages/mongo/mongo_error.hpp>
2727

28-
#include <dynamic_config/variables/MONGO_DEADLINE_PROPAGATION_ENABLED_V2.hpp>
28+
#include <dynamic_config/variables/USERVER_DEADLINE_PROPAGATION_ENABLED.hpp>
2929

3030
USERVER_NAMESPACE_BEGIN
3131

@@ -454,7 +454,7 @@ CDriverPoolImpl::ConnPtr CDriverPoolImpl::Pop() {
454454
std::optional<engine::Deadline::Duration> inherited_timeout{};
455455

456456
const auto dynamic_config = GetConfig();
457-
if (dynamic_config[::dynamic_config::MONGO_DEADLINE_PROPAGATION_ENABLED_V2]) {
457+
if (dynamic_config[::dynamic_config::USERVER_DEADLINE_PROPAGATION_ENABLED]) {
458458
HandleCancellations(queue_deadline, inherited_timeout);
459459
}
460460

postgresql/dynamic_configs/POSTGRES_CONNECTION_POOL_SETTINGS.yaml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ default: {}
22
description: |
33
Dynamic config that controls connection pool settings of PostgreSQL driver.
44
5-
Dictionary keys can be either the service **component name** (not database name!)
6-
or `__default__`. The latter configuration is applied for every non-matching
5+
Dictionary keys can be either the value of `name_alias` static configuration option of the PostgreSQL component
6+
(**not database name!**) or `__default__`. The latter configuration is applied for every non-matching
77
PostgreSQL component of the service.
88
99
Take note that it overrides the static configuration values of the service!
@@ -41,19 +41,30 @@ schema:
4141
minimum: 0
4242
default: 4
4343
x-usrv-cpp-type: std::size_t
44+
description: |
45+
Number of connections created initially by PostgreSQL component instance to each of the provided
46+
PostgreSQL hosts. Connections are kept even without requests.
4447
max_pool_size:
4548
type: integer
4649
minimum: 1
4750
default: 15
4851
x-usrv-cpp-type: std::size_t
52+
description: |
53+
Maximum number of connections that can be created by PostgreSQL component instance to each of
54+
the provided hosts for "connlimit_mode: manual". Should not be less than `min_pool_size`.
4955
max_queue_size:
5056
type: integer
5157
minimum: 1
5258
default: 200
59+
description: |
60+
Maximum number of clients waiting for a connection. Exception is thrown if a new request
61+
exceeds this limit.
5362
connecting_limit:
5463
type: integer
5564
minimum: 0
5665
default: 0
66+
description: |
67+
Limit for concurrent establishing connections number per PostgreSQL host (0 - unlimited).
5768
required:
5869
- min_pool_size
5970
- max_pool_size

postgresql/dynamic_configs/POSTGRES_CONNECTION_SETTINGS.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ description: |
33
Dynamic config that controls settings for newly created connections of
44
PostgreSQL driver.
55
6-
Dictionary keys can be either the service **component name** (not database name!)
7-
or `__default__`. The latter configuration is applied for every non-matching
6+
Dictionary keys can be either the value of `name_alias` static configuration option of the PostgreSQL component
7+
(**not database name!**) or `__default__`. The latter configuration is applied for every non-matching
88
PostgreSQL component of the service.
99
1010
Take note that it overrides the static configuration values of the service!

postgresql/dynamic_configs/POSTGRES_STATEMENT_METRICS_SETTINGS.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ default: {}
22
description: |
33
Dynamic config that controls statement metrics settings for specific service.
44
5-
Dictionary keys can be either the service **component name** (not database name!)
6-
or `__default__`. The latter configuration is applied for every non-matching
5+
Dictionary keys can be either the value of `name_alias` static configuration option of the PostgreSQL component
6+
(**not database name!**) or `__default__`. The latter configuration is applied for every non-matching
77
PostgreSQL component of the service.
88
99
The value of `max_statement_metrics` controls the maximum size of LRU-cache

0 commit comments

Comments
 (0)