| 193 | } |
| 194 | |
| 195 | void insert(uint64_t reqId, const InFlightShardRequest& req) { |
| 196 | auto [reqIt, inserted] = _reqs.insert({reqId, req}); |
| 197 | |
| 198 | // TODO i think we can just assert inserted, we never need this |
| 199 | // functionality |
| 200 | |
| 201 | if (inserted) { |
| 202 | // we have never seen this shard request. |
| 203 | // technically we could get the same time twice, but in practice |
| 204 | // we won't, so just assert it. |
| 205 | ALWAYS_ASSERT(_pq.insert({req.sentAt, reqId}).second); |
| 206 | } else { |
| 207 | // we had already seen this. make sure it's for the same stuff, and update pq. |
| 208 | ALWAYS_ASSERT(reqIt->second.txnId == req.txnId); |
| 209 | ALWAYS_ASSERT(reqIt->second.shid == req.shid); |
| 210 | ALWAYS_ASSERT(_pq.erase(reqIt->second.sentAt) == 1); // must be already present |
| 211 | ALWAYS_ASSERT(_pq.insert({req.sentAt, reqId}).second); // insert with new time |
| 212 | reqIt->second.sentAt = req.sentAt; // update time in existing entry |
| 213 | } |
| 214 | } |
| 215 | }; |
| 216 | |
| 217 | struct CDCReqInfo { |