This reverts the revert commit 85f266319f586634df631a7438ffa6892aabeb9a
This patch re-applies D7674 and D7691, as well as a one-line addition to which were reverted in D7729 due to breakages on master (TSAN + flakiness across all builds).
Now that we've backported a number of changes that fix the instability issues, it's time to try applying these patches again.
This patch also includes a one-line addition to accommodate D7848.