This should fix a race condition when a prepare is called right before the db connection is garbage collected.