Open arekt opened 3 months ago
Thank you for bringing this to our attention.
The SDK is not designed to be initialized pre-fork and then used post-fork. This is because the SDK creates a thread to retrieve flag data, but that thread isn't copied when the process is forked. If the process is forked before that data is retrieved, the forked copy will never have any flag data. If it is forked after the data is retrieved, it will always have stale data.
I will look into the changes surrounding Process.warmup and see what we can do to better support that change.
Again, thank you for letting us know!
@keelerm84 Thank you for looking at this. After your description looks like maybe it would be nice to have option to start event retrieving thread after delay or first request. Ideally Ruby or Rails in our case Sidekiq would have callback after warmup you can use for this.
I see the value to be able to use Process.warmup
even without threads or fork like in example above.
@arekt I believe as a temporary workaround solution you could re-initialize the LaunchDarkly client in the startup
Sidekiq hook, since it runs after Process.warmup
e.g.:
Sidekiq.configure_server do |config|
config.on(:startup) do
# Re-initialize LD...
end
end
Is this a support request? Not sure we need it anymore. We had to remove all feature flags from our background jobs as application was not working reliably. It took time to find out if the problem is related to Sidekiq, this library, Ruby or our code.
Describe the bug Related to: https://github.com/sidekiq/sidekiq/issues/6279 When gem is used in the Ruby 3.3.1 application after
Process.warmup
you can not get feature flags reliably.To reproduce cat reproduce_problem.rb
cat Gemfile
Expected behavior A clear and concise description of what you expected to happen.
Logs
SDK version gem "launchdarkly-server-sdk", "~> 8.4.2" (It happens with earlier 7.* as well.
Language version, developer tools Ruby 3.3.1
OS/platform MacOS 14.5 M1/M2 Ubuntu 2204 amd64
Additional context Process.warmup in Ruby 3.3 is a new feature and probably some extra work is required to make this gem work reliably.