I have a question about the concurrency of Solana's transaction.
https://github.com/solana-labs/example-helloworld/blob/master/src/program-rust/src/lib.rs#L43
Isn't greeting_account.counter corrupted when the same instruction is run from another client at exactly the same time?
If the result is correct, does one transaction wait for the preceding transaction to finish? Or is it an immediate error?
So solana supports parallel computing mean two transactions can be processed in parallel, what will happen here is that whichever transaction gets processed first will increment the counter first, if it started at 0 txn A will make it 1 and then txn B will make it 2.
In solana transactions are atomic. In this scenario it may not be a problem since you can keep incrementing counter but let's imagine you have a 5 NFTs that people can mint, if atomicity is not maintained here then you can have 6 people trying to mint 5 NFTs and one person getting an error or if your dealing with multisig wallets you can have two people making a withdraw at the same time. To avoid this you have to implement a mutex which locks the resource when one person makes a request preventing others from accessing it until the person finishes the instruction