Skip to content

Fix lost parameter thread-count increments on first insertion - #3653

Open
hutiefang76 wants to merge 1 commit into
alibaba:1.8from
hutiefang76:frank/oss-param-increment-20261007-01a11186
Open

hutiefang76 wants to merge 1 commit into
alibaba:1.8from
hutiefang76:frank/oss-param-increment-20261007-01a11186

Conversation

@hutiefang76

Copy link
Copy Markdown

Describe what this PR does / why we need it

Prevent ParameterMetric.addThreadCount from losing an increment when two callers first encounter the same parameter. Previously the first caller published a zero counter, another caller incremented it, and the first caller replaced the entry with a different counter initialized to one.

Does this pull request fix one issue?

Related to #1462 and #3058. This fixes the first-insertion increment race only, and deliberately does not close either broader issue.

Describe how you did it

Publish the counter initialized to one with a single putIfAbsent. Increment the existing counter when another caller already published it. Apply the same change to scalar, array and collection arguments.

Describe how to verify it

  • JDK 17 affected-module verify: ParameterMetricTest,ParamFlowCheckerTest,ParamFlowDefaultCheckerTest,ParamFlowPartialIntegrationTest,ParamFlowSlotTest,ParameterMetricStorageTest — 22 tests passed.
  • JDK 8 toolchain: ParameterMetricTest — 5 tests passed.
  • Three deterministic regression cases interleave a second call after insertion but before the first putIfAbsent returns. Each asserts a count of two, a single cache entry and subsequent decrement cleanup. No sleeps or probabilistic stress loops.

Special notes for reviews

This does not address the concurrent decrement/removal race described in #3058 or change cache eviction policy. It is a focused part of the counter-map concurrency concerns in #1462.

AI assistance: DeepSeek and Codex assisted implementation, tests and this description.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant