wso2 / wso2/reference-implementation-cms0057f
Replace in-memory stores with persistent/distributed storage for multi-instance deployment compatibility
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 19
- Forks
- 23
- PR merge metrics
- No merged PRs in 30d
Description
Summary
Several components use isolated in-memory maps as runtime stores. These stores are not suitable for production multi-instance deployments because:
- All state is lost on service restart
- State is not shared across instances (horizontal scaling breaks job polling)
- Stores grow unboundedly over time (memory exhaustion risk)
This issue was identified during code review of PR #256 (comment: https://github.com/wso2/reference-implementation-cms0057f/pull/256#discussion_r2928512908), requested by @anjuchamantha.
Affected In-Memory Stores
| File | Variable | Type | Risk |
|---|---|---|---|
fhir-service/bulk_member_match.bal (line 31) |
bulkMatchJobStore |
map<BulkMemberMatchJob> |
Async job state lost on restart; not visible across instances |
fhir-service/davinci_data_export.bal (line 31) |
davinciExportJobStore |
map<DaVinciExportJob> |
Async export job state lost on restart; not visible across instances |
fhir-service/service.bal (line 1504) |
consentStore |
map<Consent> |
Consent decisions lost on restart; inconsistent across instances |
file-service/inMemoryStorage.bal (line 17) |
exportResults |
map<ExportTask> |
Export task results lost on restart |
bulk-export-client/inMemoryStorage.bal (line 17) |
exportTasks |
map<ExportTask> |
Export task state lost on restart |
Recommended Actions
- Short-term: Ensure TTL-based eviction is consistently applied to all job stores (currently partially implemented in
bulk_member_match.balanddavinci_data_export.bal, but not inconsentStoreor thefile-service/bulk-export-clientstores). - Medium-term: Add a maximum capacity guard with eviction of oldest/failed entries before inserting new ones.
- Long-term: Replace in-memory maps with a persistent store (e.g., a database) or a distributed cache (e.g., Redis) to support multi-instance deployments and survive restarts.
References
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the five listed files and compare the existing TTL handling in bulk_member_match.bal and davinci_data_export.bal with the other stores. Trace how each job, consent, and export store is written and read, then review PR #256 and its discussion for context. Done means the affected state is no longer dependent on isolated in-memory maps and supports the stated restart and multi-instance requirements.
Written by the indexing model from the issue text.
Assessment
- Domain
- backend, distributed-systems, infrastructure
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100