Hotfix: CC balance stale JPA L1 cache in AgentAndCcApplicationController (#19752)#19786
Open
buddhika75 wants to merge 1 commit intoruhunu-prodfrom
Open
Hotfix: CC balance stale JPA L1 cache in AgentAndCcApplicationController (#19752)#19786buddhika75 wants to merge 1 commit intoruhunu-prodfrom
buddhika75 wants to merge 1 commit intoruhunu-prodfrom
Conversation
Replace collectingCentre.getBallance() with a JPQL scalar query in all
13 handlers of AgentAndCcApplicationController.
Root cause: institutionFacade.findWithoutCache() uses em.find() with
CacheRetrieveMode.BYPASS, which only bypasses the EclipseLink L2
(shared) cache. When an outer JTA transaction is active (from the
calling EJB chain), InstitutionFacade joins that transaction and shares
its persistence context. If the Institution entity is already in that
L1 cache with a stale balance, em.find() returns the stale object
without hitting the database — causing AgentHistory records to store an
incorrect balanceBeforeTransaction.
Fix: added fetchCurrentBalance(Long ccId) which uses JPQL
("SELECT i.ballance FROM Institution i WHERE i.id = :ccId"). JPQL
always bypasses both L1 and L2 caches and reads directly from the DB.
Applied to all 13 handlers. The entity is still loaded via
findWithoutCache for the editAndCommit merge.
Confirmed incident: RCC367 (Monaragala) on 22 Mar 2026 — bills 020009
and 020012 both stored balanceBefore=-8660.75 (stale pre-020006 value)
instead of the correct post-020007 value of +1306.75.
Closes #19752
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
51910087f2from PR Hotfix: CC balance stale JPA L1 cache in AgentAndCcApplicationController (#19752) #19754 (already merged to master)AgentAndCcApplicationControllerChanges
AgentAndCcApplicationController.java: Refresh JPA entity before reading CC balance to bust L1 cacheTest plan
Closes #19752
🤖 Generated with Claude Code