Skip to content

Commit ff96568

Browse files
committed
feat postgres: move experiment to config option
commit_hash:37499bbb5d5359ecc46a05670834a9f813c63132
1 parent 80d3b34 commit ff96568

File tree

9 files changed

+10
-9
lines changed

9 files changed

+10
-9
lines changed

core/include/userver/utils/impl/userver_experiments.hpp

-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ extern UserverExperiment kJemallocBgThread;
5858
extern UserverExperiment kCoroutineStackUsageMonitorExperiment;
5959
extern UserverExperiment kServerSelectionTimeoutExperiment;
6060
extern UserverExperiment kPgCcExperiment;
61-
extern UserverExperiment kPgDeadlinePropagationExperiment;
6261
extern UserverExperiment kYdbDeadlinePropagationExperiment;
6362

6463
} // namespace utils::impl

core/src/utils/impl/userver_experiments.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ UserverExperiment kJemallocBgThread{"jemalloc-bg-thread"};
8686
UserverExperiment kCoroutineStackUsageMonitorExperiment{"coro-stack-usage-monitor"};
8787
UserverExperiment kServerSelectionTimeoutExperiment{"mongo-server-selection-timeout"};
8888
UserverExperiment kPgCcExperiment{"pg-cc"};
89-
UserverExperiment kPgDeadlinePropagationExperiment{"pg-deadline-propagation"};
9089
UserverExperiment kYdbDeadlinePropagationExperiment{"ydb-deadline-propagation"};
9190

9291
} // namespace utils::impl

postgresql/functional_tests/basic_chaos/static_config.yaml

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# yaml
22
components_manager:
3-
userver_experiments:
4-
pg-deadline-propagation: true
53
components:
64
handler-chaos-postgres:
75
path: /chaos/postgres

postgresql/include/userver/storages/postgres/component.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ namespace components {
136136
/// connecting_limit | limit for concurrent establishing connections number per pool (0 - unlimited) | 0
137137
/// connlimit_mode | max_connections setup mode (manual or auto), also see @ref scripts/docs/en/userver/pg_connlimit_mode_auto.md | auto
138138
/// error-injection | artificial error injection settings, error_injection::Settings | --
139+
/// deadline-propagation-enabled | whether deadline propagation sets statement timeout | true
139140

140141
// clang-format on
141142

postgresql/include/userver/storages/postgres/options.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,8 @@ struct ConnectionSettings {
253253
/// Execute discard all after establishing a new connection
254254
DiscardOnConnectOptions discard_on_connect = kDiscardAll;
255255

256+
bool deadline_propagation_enabled = true;
257+
256258
/// Helps keep track of the changes in settings
257259
SettingsVersion version{0U};
258260

postgresql/src/storages/postgres/component.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,10 @@ additionalProperties: false
268268
type: boolean
269269
description: execute discard all on new connections
270270
defaultDescription: true
271+
deadline-propagation-enabled:
272+
type: boolean
273+
description: whether statement timeout is affected by deadline propagation
274+
defaultDescription: true
271275
monitoring-dbalias:
272276
type: string
273277
description: name of the database for monitorings

postgresql/src/storages/postgres/deadline.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ void CheckDeadlineIsExpired(const dynamic_config::Snapshot& config) {
2424

2525
TimeoutDuration AdjustTimeout(TimeoutDuration timeout, bool& adjusted) {
2626
adjusted = false;
27-
if (!USERVER_NAMESPACE::utils::impl::kPgDeadlinePropagationExperiment.IsEnabled()) {
28-
return timeout;
29-
}
3027

3128
const auto inherited_deadline = server::request::GetTaskInheritedDeadline();
3229
if (!inherited_deadline.IsReachable()) return timeout;

postgresql/src/storages/postgres/detail/connection_impl.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ TimeoutDuration ConnectionImpl::CurrentNetworkTimeout() const {
676676

677677
void ConnectionImpl::SetConnectionStatementTimeout(TimeoutDuration timeout, engine::Deadline deadline) {
678678
timeout = testsuite_pg_ctl_.MakeStatementTimeout(timeout);
679-
if (IsPipelineActive()) {
679+
if (IsPipelineActive() && settings_.deadline_propagation_enabled) {
680680
timeout = AdjustTimeout(timeout, deadline_propagation_is_active_);
681681
}
682682
if (current_statement_timeout_ != timeout) {
@@ -689,7 +689,7 @@ void ConnectionImpl::SetConnectionStatementTimeout(TimeoutDuration timeout, engi
689689

690690
void ConnectionImpl::SetStatementTimeout(TimeoutDuration timeout, engine::Deadline deadline) {
691691
timeout = testsuite_pg_ctl_.MakeStatementTimeout(timeout);
692-
if (IsPipelineActive()) {
692+
if (IsPipelineActive() && settings_.deadline_propagation_enabled) {
693693
timeout = AdjustTimeout(timeout, deadline_propagation_is_active_);
694694
}
695695
if (current_statement_timeout_ != timeout) {

postgresql/src/storages/postgres/postgres_config.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ ConnectionSettings ParseConnectionSettings(const ConfigType& config) {
7070
settings.discard_on_connect = config["discard-all-on-connect"].template As<bool>(true)
7171
? ConnectionSettings::kDiscardAll
7272
: ConnectionSettings::kDiscardNone;
73+
settings.deadline_propagation_enabled = config["deadline-propagation-enabled"].template As<bool>(true);
7374

7475
return settings;
7576
}

0 commit comments

Comments
 (0)