update defrag and pruning workers to use the cached cursors, flush the chain state before pruning