bigcommerce / gruf

gRPC Ruby Framework
https://github.com/bigcommerce/gruf
MIT License
626 stars 73 forks source link

fix a code reload concurency issue #175

Closed ximus closed 1 year ago

ximus commented 1 year ago

What? Why?

I started getting the following error:

[GRPC] app err:#<GRPC::ActiveCall:0x000000011501e260>, status:13:please, finish your configuration and call Zeitwerk::Loader#setup once all is ready

When Zeitwerk does a reload (here), it "un-setups" (#unload) itself before a rebuild of itself (#setup). But it's not thread-safe so if two threads get in there, if the second one hits reload before the first has finished to re-setup. Then it's going to detect that setup hasn't run and throw the finish your configuration and call Zeitwerk::Loader#setup error.

I think i started getting this after the following gem udpate(?):

google-protobuf (3.21.9)
grpc (1.50.0)
grpc-tools (1.50.0)

Maybe there were changes in concurency in those gems. Maybe it's something else, got lots of changes merging on this repo. But it fixed my app so I'm using this for now.

How was it tested?

my local app consistently failed. my local app now consistently works.

ximus commented 1 year ago

@splittingred added the changelog entry. Sorry about the branch name, should have made a feature branch. Let me know if you want a new PR and branch to help run tests. Thanks

splittingred commented 1 year ago

@ximus Not a problem. I pulled it down and ran tests+e2e locally. Thanks!