Generalize bulk_operations logic

LMS-11366

@nasthagiri @cpennington please review
I don't understand how to do this beyond what's already there. When the outermost exits, it calls `_clear_bulk_write_record` which del's the record. I would think that suffices. (Which reminds me, should we have a finally clause in `bulk_operations`?)