QuicSentPacketManager::OnConnectionMigration() shouldn't mark packet for retransmission if the packet doesn't have transmittable frames. If such packet is still in flight, mark it not to contribute to congestion control.

PiperOrigin-RevId: 353659204
Change-Id: I3bb5f9b89f9c415349ba52614c7522209bd5d047
diff --git a/quic/core/quic_sent_packet_manager.cc b/quic/core/quic_sent_packet_manager.cc
index 73ee59e..4f2b200 100644
--- a/quic/core/quic_sent_packet_manager.cc
+++ b/quic/core/quic_sent_packet_manager.cc
@@ -661,7 +661,9 @@
   QUIC_BUG_IF(transmission_type != LOSS_RETRANSMISSION &&
               transmission_type != RTO_RETRANSMISSION &&
               !unacked_packets_.HasRetransmittableFrames(*transmission_info))
-      << "transmission_type: " << transmission_type;
+      << "packet number " << packet_number
+      << " transmission_type: " << transmission_type << " transmission_info "
+      << transmission_info->DebugString();
   // Handshake packets should never be sent as probing retransmissions.
   DCHECK(!transmission_info->has_crypto_handshake ||
          transmission_type != PROBING_RETRANSMISSION);
@@ -1610,10 +1612,12 @@
       unacked_packets_.RemoveFromInFlight(packet_number);
       // Retransmitting these packets with PATH_CHANGE_RETRANSMISSION will mark
       // them as useless, thus not contributing to RTT stats.
-      MarkForRetransmission(packet_number, PATH_RETRANSMISSION);
-    } else {
-      it->state = NOT_CONTRIBUTING_RTT;
+      if (unacked_packets_.HasRetransmittableFrames(packet_number)) {
+        MarkForRetransmission(packet_number, PATH_RETRANSMISSION);
+        DCHECK_EQ(it->state, NOT_CONTRIBUTING_RTT);
+      }
     }
+    it->state = NOT_CONTRIBUTING_RTT;
   }
   return old_send_algorithm;
 }