Skip to content

fix(gofeatureflag): issue when using inProcess with high concurency#1781

Open
thomaspoignant wants to merge 8 commits intomainfrom
fix-wasm-concurrency
Open

fix(gofeatureflag): issue when using inProcess with high concurency#1781
thomaspoignant wants to merge 8 commits intomainfrom
fix-wasm-concurrency

Conversation

@thomaspoignant
Copy link
Copy Markdown
Member

This PR

Addressing issue when concurrent access on the evaluator.
This issue is adding a pool for the evaluation in order to avoid sharing the instances.

Related Issues

closes #1775 thomaspoignant/go-feature-flag#5135

Signed-off-by: Thomas Poignant <thomas.poignant@gofeatureflag.org>
@thomaspoignant thomaspoignant requested a review from a team as a code owner April 22, 2026 15:20
Signed-off-by: Thomas Poignant <thomas.poignant@gofeatureflag.org>
@thomaspoignant
Copy link
Copy Markdown
Member Author

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a WasmEvaluatorPool to handle concurrent flag evaluations and adds a wasmEvaluatorPoolSize configuration option. The review feedback identifies a race condition in the preWarmWasm method and suggests moving the pre-warming logic into the WasmEvaluatorPool constructor to ensure thread safety. Additionally, it is recommended to encapsulate the multiple volatile configuration fields into a single immutable object to prevent inconsistent states during evaluation.

this.evaluationContextEnrichment = configFlags.getEvaluationContextEnrichment();
// We call the WASM engine to avoid a cold start at the 1st evaluation
this.evaluationEngine.preWarmWasm();
this.evaluationPool.preWarmWasm();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

If the WasmEvaluatorPool constructor is updated to pre-warm instances during allocation (as suggested in the WasmEvaluatorPool review), this explicit call becomes redundant and can be removed to simplify the initialization sequence.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a WasmEvaluatorPool to enable concurrent flag evaluations in the InProcessEvaluator and adds a configuration option for the pool size. The changes also include thread-safety improvements using volatile fields and a new concurrency test. Feedback focuses on enhancing the robustness of the pool management, grouping related configuration fields into an immutable object for atomic updates, and ensuring consistent state capture during evaluation.

Signed-off-by: Thomas Poignant <thomas.poignant@gofeatureflag.org>
Signed-off-by: Thomas Poignant <thomas.poignant@gofeatureflag.org>
Signed-off-by: Thomas Poignant <thomas.poignant@gofeatureflag.org>
@thomaspoignant
Copy link
Copy Markdown
Member Author

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a WasmEvaluatorPool to enable concurrent flag evaluations and refactors the InProcessEvaluator to use an immutable EvaluatorState for thread-safe configuration updates. Feedback suggests using Schedulers.io() for the polling interval to prevent blocking computation threads and recommends throwing an exception if the WASM pool fails to initialize properly.

Signed-off-by: Thomas Poignant <thomas.poignant@gofeatureflag.org>
Signed-off-by: Thomas Poignant <thomas.poignant@gofeatureflag.org>
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.

GO Feature Flag provider IN_PROCESS mode fails under concurrent access

1 participant