G'day. At the moment we have some parts of the Puppet code that have a lurking bug around ActiveRecord: when we fork, if an AR database connection is open, we will break that connection in the parent when the child exits.
This turns up in things like tagmail, but is a risk everywhere that we fork that the same problem will come up. (This is going to be true in the spec suite, also, where we have a few places that we fork for concurrency wing-and-a-prayer testing and stuff) I can see two solutions to the problem, rather than just the symptom: Option one, we patch `fork` at runtime to behave like `popen` and the backtickts, which is that the close all the file handles. This will absolutely solve the problem, and is as safe as `popen` is - which is to say, pretty damn solid. The cost of that is that now you *can't* retain an open file descriptor over a fork, even if you want to. It looks like none of our core code tries to do that anyhow, but will we eventually care, or a third party? Who can say. :/ Also, this is divergent to how Ruby core handles the file descriptors across `fork`, so we have moved further into the special "not quite Ruby" language we write code in. Option two, we patch this every place in the code that we fork, or direct them through `fork_closing_files` along the way. That will solve the problem everywhere that someone notices this is an issue, without question. The cost is that every single person who touches the code needs to know that `fork` behaves badly in some cases, and that they should call our wrapper instead. Which means that we are going to see this problem come back again and again. I would love feedback on what people think is the best strategy here. People who work for Puppet Labs are likely to be told this, so the community is really where this is likely to bite... -- Daniel Pittman ⎋ Puppet Labs Developer – http://puppetlabs.com ♲ Made with 100 percent post-consumer electrons -- You received this message because you are subscribed to the Google Groups "Puppet Developers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
