WIP: Fix rollup failure for delayed metrics bug

This is really a very raw version of what I think should solve the problem. I added a test to `ShardStateIntegrationTest` to prove that it works. But the only reason I have marked this PR as WIP is because I believe there are a lot of other cases that could be tested and I am going to add a test for each and every case before marking this PR as ready for review.