Prepare all statements exactly once per MetadataDb object.
Avoid crash when flushing upload state machine.
Regulate input to snapshot state machine pool by number of chunks, not number of files.