I am new in this world and I am trying to understand some simple concept of Blockchain and the propagation of transaction. Let say that a transaction x is made so from what i understand until now this transaction will be propagate in the network and in particular in the "pool transaction" of the miners. The miners than will take a bunch of transaction, put them in a block and mine the block, than the block is confirmed and propagated to all nodes. My question is: there are 2 miners A and B that both receive the x transaction in their pools. Now, miner A decide to put in a block transaction: "w r t x" and start to mine the block. Miner B decide to put in his block transaction: "k y x l", and start to mine the block.
Both succeed in mining the block correctly at the same time, but the blocks cannot be both confirmed and added to the blockchain since they contain a common transaction.
1)How is this situation manage by the blockchain? 2)Who performs the check to avoid that two blocks contain totally different transaction? 3)What happens to the transaction that were put in the block that will not be added to the blockchain? If the block is completely wasted it seems to me that a lot of energy was consumed to mine a block that is not validate due to a one transaction over possibly hundreds or thousands and that is pretty frustrating.