safe_init_db leaks temporary file descriptor
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
loggerhead |
Fix Released
|
Low
|
Matt Nordhoff |
Bug Description
From loggerhead/
def safe_init_
# To avoid races around creating the database, we create the db in
# a temporary file and rename it into the ultimate location.
fd, temp_path = tempfile.
con = dbapi2.
...
The file descriptor returned by mkstemp() is completely ignored, and left open forever.
Steps to reproduce:
>>> from loggerhead.
>>> for i in xrange(100):
... safe_init_
... "binary primary key, data binary)")
...
Then check something like "lsof -n". Look, 100 open copies of /tmp/test.sql!
I assume the simplest fix would be throwing in an "os.close(fd)". It'd be even better if pysqlite had some "connect_to_fd" function, but I don't know if that's the case.
Related branches
Changed in loggerhead: | |
importance: | Undecided → Low |
status: | New → Confirmed |
Changed in loggerhead: | |
status: | Fix Committed → Fix Released |
I added an os.close(fd) in revision 336 of the trunk. I hope you don't mind.
I don't see how this could introduce any race conditions that weren't already there, so it seems okay to me.