So I'm learning about STP and I recently been taught that when the topology is changed due to direct or indirect Link failure a Mac Instability could occur, So I was wondering, If the blocked port is going to transition and end up in the learning state where it can learn about the mac addresses in the network and start updating and populating its mac table, then why can be there a Mac instability after that, shouldn't the learning state prevent that from happening by learning the new interfaces corresponding to the macs?
When a link fails, a directly connected switch removes that port's MAC associations from its MAC table. This usually causes the switch to simply re-learn the removed MAC addresses, temporarily flooding them before that learning takes place.
However, a switch that isn't directly involved in the failed link can't know whether the port it has associated with a certain remote MAC is or isn't the right port after the topology change. It is possible that the remote MAC is now behind another of its ports, where the path was previously blocked by STP. Forwarding a frame through the wrong branch of the new spanning tree may miss the destination.
Usually, this is sorted out quickly because the first frame sent by that MAC address corrects the table. Remember that learning is a continuous process.
Also, that instability can be mostly avoided by carefully designing your network in the right way - especially chains and rings are prone to this problem. Flat trees with more routed ports (and less STP) are practically immune.