Early quitters never win. China should have pushed into Hanoi and replaced the government and army command. Vietnam was utterly spent after their war with the US and if China accepted additional losses, it would have also remodeled Vietnam's diplomacy lastingly. In fact, the attritional war throughout the 80s till 90s did exactly this - it was Vietnam who sued for peace and normalization, not the other way around. It would have been better to fight that same attritional war South of Hanoi than at Laoshan, in retrospect.
So much for China's lessons from the Sino-Vietnam war that China could learn from, in regards to it's support to Russia. It is better to fight the war against America in the Ukraine now than to have to fight it later along the sino-russian border if Russia falls.