Skip to content
This repository was archived by the owner on Oct 6, 2023. It is now read-only.

Commit 8a0f878

Browse files
committed
fix(bam): services cache too restrictive (#711)
* fix(bam): services cache too restrictive * fix(mysql_connection): atomic operation not really atomic REFS: MON-12070
1 parent a5e872e commit 8a0f878

File tree

4 files changed

+20
-8
lines changed

4 files changed

+20
-8
lines changed

CHANGELOG.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# Changelog
22

3+
## 20.10.11
4+
5+
### Fixes
6+
7+
*bam*
8+
9+
A ba configured with boolean expressions could not anymore load its services
10+
states because of a regression.
11+
312
## 20.10.10
413

514
### Fixes
@@ -20,7 +29,7 @@ A ba configured with best status was initialized in state OK. And when KPI were
2029
added, there status was always worst than OK (best case was OK). So even if all
2130
the kpi were in critical, the state appeared as OK.
2231

23-
The cache in bam is lighter, only needed services are loaded. Metrics are no
32+
The cache in bam is lighter, metrics are no
2433
more loaded. And queries to load the cache are parallelized.
2534

2635
*mysql_connection*

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ set_target_properties(berpc PROPERTIES COMPILE_FLAGS "-fPIC")
171171
# Version.
172172
set(CENTREON_BROKER_MAJOR 20)
173173
set(CENTREON_BROKER_MINOR 10)
174-
set(CENTREON_BROKER_PATCH 10)
174+
set(CENTREON_BROKER_PATCH 11)
175175
if (CENTREON_BROKER_PRERELEASE)
176176
set(CENTREON_BROKER_VERSION "${CENTREON_BROKER_MAJOR}.${CENTREON_BROKER_MINOR}.${CENTREON_BROKER_PATCH}-${CENTREON_BROKER_PRERELEASE}")
177177
else ()

bam/src/configuration/reader_v2.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -364,10 +364,11 @@ void reader_v2::_load(bam::hst_svc_mapping& mapping) {
364364
// XXX : expand hostgroups and servicegroups
365365
std::promise<database::mysql_result> promise;
366366
_mysql.run_query_and_get_result(
367-
"SELECT DISTINCT h.host_id, s.service_id, h.host_name, s.service_description,service_activate FROM "
368-
"service s LEFT JOIN host_service_relation AS hsr ON s.service_id=hsr.service_service_id "
369-
"LEFT JOIN host AS h ON hsr.host_host_id=h.host_id LEFT JOIN mod_bam_kpi k ON "
370-
"h.host_id=k.host_id AND k.service_id=s.service_id WHERE k.kpi_type='0'",
367+
"SELECT h.host_id, s.service_id, h.host_name, "
368+
"s.service_description,service_activate FROM "
369+
"service s LEFT JOIN host_service_relation hsr ON "
370+
"s.service_id=hsr.service_service_id "
371+
"LEFT JOIN host h ON hsr.host_host_id=h.host_id",
371372
&promise, 0);
372373
database::mysql_result res(promise.get_future().get());
373374
while (_mysql.fetch_row(res))

core/src/mysql_connection.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,15 +238,17 @@ void mysql_connection::_commit(mysql_task* t) {
238238
fmt::format("Error during commit: {}", ::mysql_error(_conn)));
239239
log_v2::sql()->error("mysql_connection: {}", err_msg);
240240
set_error_message(err_msg);
241-
if (--task->count == 0)
241+
int c = atomic_fetch_sub(&task->count, 1) - 1;
242+
if (c == 0)
242243
task->promise->set_value(true);
243244
} else {
244245
/* No more queries are waiting for a commit now. */
245246
_need_commit = false;
246247

247248
/* Commit is done on each connection. If task->count is 0, then we are on
248249
* the last one. It's time to release the future boolean. */
249-
if (--task->count == 0)
250+
int c = atomic_fetch_sub(&task->count, 1) - 1;
251+
if (c == 0)
250252
task->promise->set_value(true);
251253
}
252254
}

0 commit comments

Comments
 (0)