harness / ff-ruby-server-sdk

Ruby Server SDK for integrating with Harness Feature Flag service.
https://www.harness.io/
Apache License 2.0
3 stars 5 forks source link

FFM-12192 Use client Singleton / Lock eval & target map clone operation #48

Closed erdirowlands closed 1 day ago

erdirowlands commented 1 day ago

What

Theory

Theory is when we clone the evaluation metrics map, the evaluation thread can and will modify the original map concurrently, resulting in data corruption. Theory extends to the Segment fault being caused by this access too.

Also, the cf_client uses a class variable which is not thread safe, which could be causing issues.

Fix

Lock the cloning operation with a mutex Replace the client class variable with a Singleton

Testing