Assume the Receiver has recieved the PUBREL from the Sender, according to the standard, it would discard the packet id. If the PUBCOMP message does not arrive at the Sender successfully, the Sender would retry to send PUBREL message and when it arrives at the Receiver, the id has been discarded at the first time when PUBREL arrived. Will the sender respond a proper PUBCOMP? This means the receiver still stores the id after gets PUBREL and it is contradictory.
Most articles just tell that the Sender would retry to send but not tell why. Thanks for your kind answer.

For MQTT3.1.1 see MQTT-4.3.3-2:
MQTT v5 has similar rules but the PUBREL includes a "PUBREL Reason Code" which can be set to
0x92to indicate:In both cases the spec seems quite clear, if you receive a
PUBRELyou must respond with aPUBCOMP. So the why could be "because the spec says so", but in reality this approach just makes sense (not sending the packet would mean thePUBRELwould be resent the next time the connection is reestablished).As per the spec the ID comes from the
PUBRELpacket, not the session state (which has been deleted previously in your example), so there is no contradiction.