GeezerVison is showing github.com — fix(statistics): a read failure or a switch can no longer weaken suppression by Storypapst · Pull Request #1568 · OpenResilienceInitiative/ORISO-UserService
Conversation
Storypapst
commented
Nov 2, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
The statistics protections could quietly weaken. If the settings could not be read, the service used its defaults, so a stricter minimum dropped and message counting could restart although it was switched off. Suppression could be turned off on every profile except prod. Switching a role to Live and back forced a fresh snapshot, which undoes the point of a fixed one. And two admins saving at the same moment could both win.
What changed
- A failed or invalid settings read now answers 503 on the dashboard, and message counting stays off.
- Suppression can only be switched off when every active profile is
local or testing. Dev, Stage and Prod always keep it on.
- Switching to Live and back reuses the existing stand. A new stand comes only at the next cutoff.
- Saving takes a lock, so the second of two simultaneous saves is refused with 409.
How should I test this?
- Make the settings read fail: the dashboard answers 503 and shows no figures
- Switch a role to Live and back within one cutoff: the stand time stays the same
- Save the same setting twice at once: one save gets 409, and only one protocol line appears
Where it was verified
Only tested locally: the full suite on H2, the concurrency test and the changesets on a throwaway MariaDB 10.11. Not tested on dev.oriso.org. An independent review ran before the first push. Its findings and the CodeRabbit comments are fixed in the later commits.
For developers: test results, limits and the frontend follow-up (skip if you only need the story):
./mvnw -B -o test, Java 21: 8106 tests, 0 failures
StatisticsSettingsConcurrencyIT on MariaDB 10.11.18, REPEATABLE-READ: 4 of 4
Liquibase changesets on MariaDB 10.11.18: fresh update, rollback, hand-made table with and without the row: clean
New table statistics_settings_lock with one row, changeset 20261102_statistics_settings_lock_1562
updateSettings runs with READ_COMMITTED: a plain read earlier in the transaction would pin the snapshot on MariaDB
Spring ignores this isolation when joining an outer transaction, so updateSettings must keep opening its own
AdminDashboardStandRefresh.refreshAll: per-scope try/catch, one unreadable interval no longer aborts the others
Removed deleteScope and deleteByScope; the 14-day retention is now the only stand cleanup
Not reproduced: MariaDB deadlock 1213 on two truly concurrent first saves, unit-tested only
Merge note: userservice-master.xml takes one appended include, so a sibling changeset conflicts trivially: keep both lines
ORISO-Admin must follow in a separate PR:
dashboard GET can answer 503: show a "temporarily unavailable" state, no figures
settings PUT 409 now also covers simultaneous saves, same status as the existing revision mismatch
Refs #1562
Part of OpenResilienceInitiative/ORISO-Admin#1335
🤖 Generated with Claude Code
Summary by CodeRabbit
- Bug Fixes
- Dashboard refreshes now continue for other scopes if one scope fails.
- Existing dashboard data is retained when a scope uses a live update interval.
- Settings updates are serialized; competing updates receive a conflict instead of overwriting a newer value.
- Unavailable or invalid saved settings now report an error rather than silently using a default.
- Configuration
- Small-cell suppression can be disabled only in local and testing environments; it remains enforced in all other environments.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
…tch, Live round trip and concurrent saves
- A settings read failure or an unknown stored value no longer falls back to
weaker defaults: dashboard readers fail with 503, message counting stays off.
Saving still works on an unknown stored value, so it can be repaired.
- Small-cell suppression can only be switched off on the local and testing
profiles; prod, staging, dev, a new or no profile keep it on.
- Stands are kept while a role is Live, so switching to Live and back within
one cutoff serves the same stand instead of a fresh one.
- Saving settings locks a single row (new statistics_settings_lock table), so
two saves of the same revision cannot both pass; the second gets 409.
Refs #1562
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
- Saving settings runs READ_COMMITTED, so an earlier read in the same
transaction cannot pin a MariaDB snapshot and hide the other save.
- A deadlock between two first saves (lock row not there yet) answers 409
instead of 500.
- One unreadable snapshot interval no longer stops the refresh of the other
scopes or the retention step.
- Concurrency test runs behind the real transaction annotations and covers an
existing and a missing lock row, and a read before the save.
Refs #1562
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
coderabbitai
Bot
commented
Nov 2, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|

Warning
Review limit reached
Your organization has reached its usage spending cap. Adjust your spending cap in the billing tab.
Next included review available in 25 minutes.
Check out review usage here.
View limit details
-
Limit details: You’ve used the included review currently available. Your 119 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.
Learn how review limits work.
Review configuration:
Run configuration
-
Commits
-
Reviewing files that changed from the base of the PR and between 4b964e3 and 343618e.
Files selected for processing: 8
-
src/main/java/de/caritas/cob/userservice/api/service/statistics/AdminDashboardStatisticsService.java
src/main/java/de/caritas/cob/userservice/api/service/statistics/settings/StatisticsSettingsService.java
src/main/resources/db/changelog/changeset/20261102_statistics_settings_lock_1562/changeSet.xml
src/test/java/de/caritas/cob/userservice/api/StatisticsSettingsLockMigrationTest.java
src/test/java/de/caritas/cob/userservice/api/service/statistics/AdminDashboardStandRefreshTest.java
src/test/java/de/caritas/cob/userservice/api/service/statistics/AdminDashboardStatisticsServiceTest.java
src/test/java/de/caritas/cob/userservice/api/service/statistics/settings/StatisticsSettingsConcurrencyIT.java
src/test/java/de/caritas/cob/userservice/api/service/statistics/settings/StatisticsSettingsServiceTest.java
Recent review info
-
Run configuration
-
Commits
-
Reviewing files that changed from the base of the PR and between b8f5f0e and 4b964e3.
Files selected for processing: 17
-
src/main/java/de/caritas/cob/userservice/api/model/StatisticsSettingsLock.java
src/main/java/de/caritas/cob/userservice/api/port/out/StatisticsDashboardSnapshotRepository.java
src/main/java/de/caritas/cob/userservice/api/port/out/StatisticsSettingsLockRepository.java
src/main/java/de/caritas/cob/userservice/api/service/statistics/AdminDashboardStandRefresh.java
src/main/java/de/caritas/cob/userservice/api/service/statistics/AdminDashboardStandWriter.java
src/main/java/de/caritas/cob/userservice/api/service/statistics/AdminDashboardStatisticsService.java
src/main/java/de/caritas/cob/userservice/api/service/statistics/settings/StatisticsSettingsService.java
src/main/resources/application-prod.properties
src/main/resources/application.properties
src/main/resources/db/changelog/changeset/20261102_statistics_settings_lock_1562/changeSet.xml
src/main/resources/db/changelog/userservice-master.xml
src/test/java/de/caritas/cob/userservice/api/StatisticsSettingsLockMigrationTest.java
src/test/java/de/caritas/cob/userservice/api/adapters/web/controller/AdminDashboardStandIT.java
src/test/java/de/caritas/cob/userservice/api/service/statistics/AdminDashboardStandRefreshTest.java
src/test/java/de/caritas/cob/userservice/api/service/statistics/AdminDashboardStatisticsServiceTest.java
src/test/java/de/caritas/cob/userservice/api/service/statistics/settings/StatisticsSettingsConcurrencyIT.java
src/test/java/de/caritas/cob/userservice/api/service/statistics/settings/StatisticsSettingsServiceTest.java
Files with no reviewable changes: 2
-
- src/main/java/de/caritas/cob/userservice/api/service/statistics/AdminDashboardStandWriter.java
- src/main/java/de/caritas/cob/userservice/api/port/out/StatisticsDashboardSnapshotRepository.java
Included review availability: This review used your included allowance. 0 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 1 review per hour.
Recent review details
-
Context from checks skipped due to timeout: 5
-
- GitHub Check: CodeRabbit
- GitHub Check: mariadb-contract / MariaDB schema, statistics, scheduler lease and replica contracts
- GitHub Check: required integration tests
- GitHub Check: integration tests with the tenant filter on
- GitHub Check: test, build and Docker validation
Additional context used
-
Path-based instructions: 3
-
Liquibase changesets are append-only.
-
CodeRabbit configuration file
Files:
src/main/resources/db/changelog/userservice-master.xml
src/main/resources/db/changelog/changeset/20261102_statistics_settings_lock_1562/changeSet.xml
Check behavior against the surrounding ORISO flow, not only types.
-
CodeRabbit configuration file
Files:
src/main/java/de/caritas/cob/userservice/api/port/out/StatisticsSettingsLockRepository.java
src/main/java/de/caritas/cob/userservice/api/service/statistics/AdminDashboardStatisticsService.java
src/main/java/de/caritas/cob/userservice/api/service/statistics/AdminDashboardStandRefresh.java
src/main/java/de/caritas/cob/userservice/api/model/StatisticsSettingsLock.java
src/main/java/de/caritas/cob/userservice/api/service/statistics/settings/StatisticsSettingsService.java
Tests must be able to fail.
-
CodeRabbit configuration file
Files:
src/test/java/de/caritas/cob/userservice/api/StatisticsSettingsLockMigrationTest.java
src/test/java/de/caritas/cob/userservice/api/service/statistics/AdminDashboardStatisticsServiceTest.java
src/test/java/de/caritas/cob/userservice/api/service/statistics/AdminDashboardStandRefreshTest.java
src/test/java/de/caritas/cob/userservice/api/adapters/web/controller/AdminDashboardStandIT.java
src/test/java/de/caritas/cob/userservice/api/service/statistics/settings/StatisticsSettingsServiceTest.java
src/test/java/de/caritas/cob/userservice/api/service/statistics/settings/StatisticsSettingsConcurrencyIT.java
OpenGrep (1.30.2)
-
src/test/java/de/caritas/cob/userservice/api/StatisticsSettingsLockMigrationTest.java
-
[ERROR] 60-62: SQL query built via string concatenation passed to Statement.execute*(). Use PreparedStatement with parameterized queries instead.
(coderabbit.sql-injection.java-statement-concat)
PMD (7.28.0)
-
src/test/java/de/caritas/cob/userservice/api/StatisticsSettingsLockMigrationTest.java
-
[Medium] 63-63: CheckResultSet (Best Practices): Always check the return of one of the navigation method (next,previous,first,last) of a ResultSet.
(CheckResultSet (Best Practices))
src/main/java/de/caritas/cob/userservice/api/service/statistics/settings/StatisticsSettingsService.java
-
[Medium] 227-227: PreserveStackTrace (Best Practices): Thrown exception does not preserve the stack trace of exception 'lostToAnotherSave' on all code paths
(PreserveStackTrace (Best Practices))
Additional comments: 8
-
src/main/java/de/caritas/cob/userservice/api/model/StatisticsSettingsLock.java: 1
-
1-27: LGTM!
src/main/java/de/caritas/cob/userservice/api/port/out/StatisticsSettingsLockRepository.java: 1
-
11-17: LGTM!
src/main/resources/db/changelog/userservice-master.xml: 1
-
265-265: LGTM!
src/test/java/de/caritas/cob/userservice/api/StatisticsSettingsLockMigrationTest.java: 1
-
26-66: LGTM!
src/main/java/de/caritas/cob/userservice/api/service/statistics/settings/StatisticsSettingsService.java: 1
-
71-73: LGTM!
Also applies to: 128-171, 193-213
src/test/java/de/caritas/cob/userservice/api/service/statistics/settings/StatisticsSettingsServiceTest.java: 1
-
231-264: LGTM!
Also applies to: 326-352, 355-405
src/test/java/de/caritas/cob/userservice/api/service/statistics/settings/StatisticsSettingsConcurrencyIT.java: 2
-
95-125: LGTM!
42-44: Maintainability & Code Quality
The concurrency IT already matches a configured Maven include.
The POM's Surefire integration-tests execution includes **/*IT.*. StatisticsSettingsConcurrencyIT matches that pattern, so no rename or new include is required for the test to be eligible for the integration-test phase. The reported test run is not evidence that this class is excluded from the build.
Walkthrough
-
This PR adds lock-based serialization for statistics settings updates and changes how stored settings are read. It also changes dashboard stand refresh behavior for LIVE intervals and restricts disabling small-cell suppression to local and testing profiles.
Changes: Statistics settings
| Layer / File(s) |
Summary |
Settings lock storage src/main/java/de/caritas/cob/userservice/api/model/StatisticsSettingsLock.java, src/main/java/de/caritas/cob/userservice/api/port/out/StatisticsSettingsLockRepository.java, src/main/resources/db/changelog/changeset/20261102_statistics_settings_lock_1562/changeSet.xml, src/main/resources/db/changelog/userservice-master.xml, src/test/java/de/caritas/cob/userservice/api/StatisticsSettingsLockMigrationTest.java |
Adds the lock entity and pessimistic-lock repository. The Liquibase changeset creates the lock table and its initial row. Tests check migration and rollback behavior. |
Serialized settings updates src/main/java/de/caritas/cob/userservice/api/service/statistics/settings/StatisticsSettingsService.java, src/test/java/de/caritas/cob/userservice/api/service/statistics/settings/StatisticsSettingsServiceTest.java, src/test/java/de/caritas/cob/userservice/api/service/statistics/settings/StatisticsSettingsConcurrencyIT.java |
Settings updates acquire the lock under READ_COMMITTED before checking the supplied revision. Lock acquisition failures become ConflictException. Tests cover concurrent updates, revision checks, and lock failures. |
Setting read behavior src/main/java/de/caritas/cob/userservice/api/service/statistics/settings/StatisticsSettingsService.java, src/test/java/de/caritas/cob/userservice/api/service/statistics/settings/StatisticsSettingsServiceTest.java |
Invalid stored values and store-read failures raise ServiceUnavailableException. Message-count tracking returns false when its setting cannot be read. Tests cover these read outcomes and retaining an invalid prior value during an update. |
Dashboard stand refresh
| Layer / File(s) |
Summary |
Stand refresh and retention src/main/java/de/caritas/cob/userservice/api/service/statistics/AdminDashboardStandRefresh.java, src/main/java/de/caritas/cob/userservice/api/service/statistics/AdminDashboardStandWriter.java, src/main/java/de/caritas/cob/userservice/api/port/out/StatisticsDashboardSnapshotRepository.java, src/test/java/de/caritas/cob/userservice/api/adapters/web/controller/AdminDashboardStandIT.java, src/test/java/de/caritas/cob/userservice/api/service/statistics/AdminDashboardStandRefreshTest.java |
A LIVE interval leaves existing stands in place. Scope-wide deletion methods are removed. Refresh failures are logged per scope, and retention cleanup remains. Tests cover LIVE transitions, stand reuse, and refresh failures. |
Suppression profile rules
| Layer / File(s) |
Summary |
Profile-gated suppression src/main/java/de/caritas/cob/userservice/api/service/statistics/AdminDashboardStatisticsService.java, src/main/resources/application.properties, src/main/resources/application-prod.properties, src/test/java/de/caritas/cob/userservice/api/service/statistics/AdminDashboardStatisticsServiceTest.java |
Suppression remains active when disabling is requested outside the local and testing profiles, including when no profile is active. Configuration comments and profile tests reflect this rule. |
Estimated code review effort: 3 (Moderate) | ~25 minutes
Change: Bug fix
Sequence Diagram(s)
sequenceDiagram
participant SettingsAdmin
participant StatisticsSettingsService
participant StatisticsSettingsLockRepository
participant Database
SettingsAdmin->>StatisticsSettingsService: updateSettings with values and revision
StatisticsSettingsService->>StatisticsSettingsLockRepository: findLockedById
StatisticsSettingsLockRepository->>Database: select lock row for update
Database-->>StatisticsSettingsLockRepository: lock row or no row
StatisticsSettingsLockRepository-->>StatisticsSettingsService: locked row result
StatisticsSettingsService->>Database: create lock row if absent
Database-->>StatisticsSettingsService: lock acquired or conflict
StatisticsSettingsService-->>SettingsAdmin: update result or ConflictException
Loading
Possibly related issues
Possibly related PRs
Suggested reviewers: claude
Merge Risk: Moderate · previous review 4b964
-
Small-cell suppression could be switched off in a deployment where both a production and a local or testing profile are active; this is a regression from the previous production check. Close this gap before merging. Lock-timeout failures during concurrent settings saves may return a generic server error rather than a 409. The new migration can also fail on databases where the table was already created by hand.
Pre-merge checks: 5 · 1
-
Failed checks: 1 warning
| Check name |
Status |
Explanation |
Resolution |
| Docstring Coverage |
 |
Docstring coverage is 41.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… |
Write docstrings for the functions missing them to satisfy the coverage threshold. |
Passed checks: 5 passed
-
| Check name |
Status |
Explanation |
| Description Check |
 |
Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check |
 |
The title uses conventional commit format, names the statistics area, and describes a central change: preventing read failures or role switches from weakening suppression. |
| Linked Issues check |
 |
Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check |
 |
Check skipped because no linked issues were found for this pull request. |
| Validation Evidence |
 |
The PR changes product behavior and includes relevant automated tests in the reviewed diff. The tests cover settings read failures, suppression profiles, Live stand switching, refresh isolation, lock … |
Full details: Validation Evidence
-
Explanation
The PR changes product behavior and includes relevant automated tests in the reviewed diff. The tests cover settings read failures, suppression profiles, Live stand switching, refresh isolation, lock migration, and concurrent saves. The PR description also lists ./mvnw -B -o test with Java 21 and 8,102 tests passing, plus StatisticsSettingsConcurrencyIT with 4 of 4 tests passing on MariaDB 10.11.18.
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 41.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 12 functions across 11 files. (4 skipped: 4 unsupported.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
Finishing Touches
-
Generate docstrings
-
- Commit to this branch
- Create a new PR
Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
CodeRabbit Verify
- Run CodeRabbit Verify to test the changes in this pull request.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
coderabbitai
Bot
left a comment
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Fix comments: Fix CodeRabbit comments on this PR
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
…ock and tests
- Suppression can only be switched off when every active profile is local or
testing; prod next to local or testing keeps it on.
- A lock wait timeout or deadlock on an existing lock row now answers 409 too,
and the cause is kept.
- The lock changeset is split into table and row, each guarded with
onFail="MARK_RAN" as the master changelog requires.
- Tests: the refresh test now sees a tenant and checks the tenant and agency
stands; the suppression test requires the agency row to exist.
Refs #1562
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Uh oh!
There was an error while loading. Please reload this page.
This was referenced Nov 5, 2026
This was referenced Oct 1, 2026
Reviewers
shazia-k
shazia-k approved these changes
Shirloin
Awaiting requested review from Shirloin
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|