duritong / trocla

A password store for password creation and retrieval
Other
75 stars 18 forks source link

Add a .open() method to auto close Trocla store after you're done #37

Closed martinpfeifer closed 8 years ago

martinpfeifer commented 8 years ago

This PR adds a .open() (similar to Ruby's File.open) method to automatically close the Trocla store after you're done with it. We use trocla with mysql as backend for moneta and had massive problems with connection leaks especially if the process using trocla is not terminating quickly. In our case we use the trocla Puppet functions and this led to so many open but no longer used connections to our mysql database that after some short time it stopped working altogether. Every call to Trocla.new causes moneta to open a new database connection but trocla never closes any of them explicitly, i.e. calls the moneta close method. The only way the connections got closed is on process termination as the os then cleans up all used sockets. I think this issue over at moneta (https://github.com/minad/moneta/issues/85) is a direct consequence. I'll submit a separate PR for the puppet functions that they use this new feature.

duritong commented 8 years ago

Good catch. Thanks for the PR. I added tests and merged it. Although, I think we're actually doing the wrong thing in the end. But I will continue this discussion in duritong/puppet-trocla#18

AND I have another improvement in the pipeline I'd like to tackle before releasing a new version.