In what order do new blocks get processed? Node A receives a newest block with height h1, which it determines to be valid, and therefore stores the block on disk. A little later, it receives another block with the same height h1 but a greater amount of proof of work than the previous one. What would node A do? 

Also I am confused about the order of processing a new block. The order in the source code:

              success                          success
Check(block)-----------&gt;store block on disk------------------&gt;ReceivedBlockTransaction--------&gt;ActivateBestChain


If ReceivedBlockTransaction or ActivateBestChain were to fail, would the disk be rolled back or not? If it would rollback, why not put the receivedBlockTransaction and ActivateBestchain before store block on disk?
First to clarify:
Two competing blocks at the same height that build on the same parent block always have the same amount of proof of work, as that depends on the difficulty, which will be the same for both competitors.

Thus, a chain reorganization will only occur in practice if a competing chain tip pulls ahead of a previously accepted chain tip by accumulating a greater length.*

Bitcoin Core stores competing blocks it receives as a sidebranch, if the headers would potentially make it the best chain. Otherwise it discards them.

When chain reorganization occurs, Bitcoin Core will undo each block from the tip one at a time, reverting back to the common ancestor with the new best chain, then will apply the blocks in the new best chain one at a time until it is at the new tip.

* It is possible to construct a case around a difficulty change where competing chain tips have different difficulties at the same height. Then, the one with the higher difficulty would replace the one with lower difficulty at the same height. However, that would require a chain split of more than one block length.