lhotari commented on issue #14436: URL: https://github.com/apache/pulsar/issues/14436#issuecomment-1064991566
> I agree with your points, we should make all the Recyclable classes that could be shared among threads threadsafe. The problem is not for every class, but only for those that are meant to be passed across different threads while they are "active" (not parked into the Recycler). I was thinking initially that "thread safety" should be achieved for recycled object classes. However that would be very intrusive since "safe publication" is sufficient to reaching thread safety in this case. There aren't cases where there would be races in writes in multiple threads. The object instance is used and passed across threads and as long as "safe publication" is achieved, that is sufficient. That's why I'm actually not so sure about the solution. "Safe publication" is also a mandatory consideration for new objects so it's not actually completely limited to recycled object instance. It's probably the case, that there's already causality for most execution paths. It's just very hard to analyse the code and find the execution paths where this isn't the case. > > what about opening a discussion on Netty ? I guess that everyone who uses the Recycler has to deal with this kind of problems. Maybe they could publish some guidelines based on your thoughts. I don't think that this is a Netty problem.The usages of Netty Recycler within Netty are most likely covered with causality. I'm not sure if the Netty Recycler is used commonly outside of Netty. [There are only 8 projects in grep.app that contain "import io.netty.util.Recycler"](https://grep.app/search?q=import%20io.netty.util.Recycler) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
