user48786: As far as I know, a miner begins creating a new block as soon as it receives a valid block from another miner. It then begins to construct and hash the next block on top of the block it just received by using all the transactions it has in its memory pool.
However, there are still some transactions that are not easily confirmed (or not confirmed at all), in the BitCoin.
Can anyone explain to me why this can happen? Is it because of some transaction selection mechanism that the miners use? or is it because of the unreliability of the connecitivity between the nodes? or something else?

user50934: Transactions selected in mining blocks is not like a queue, where you wait your time and get to the front eventually.
Fees are not mandatory, but should be included in every transaction, if you have sent none, or low fees, you can still be selected (although it's highly unlikely), but the miner would be silly as they could just take the higher fee offered by someone else. Remember when you post a transaction you offer a fee.
If you owned a bakery and made 1000 loaves of bread a day, but had 1500 customers, would you sell them to someone offering $0.10 when other people are offering $1.00+.

user5406: The lifecycle of a transaction is the following:

Transaction creation:
A sender creates a transaction, he includes a list of recipients, determines which previous transaction outputs to spend, and signs it. The difference between output total and input total determines the transaction fee.
Relay:
The sender submits the transaction to the Bitcoin network. 
He simply sends it to his peers, which in turn relay it to theirs. Eventually the transaction will be seen by everyone as it spreads through the network.
Transaction selection:
From all transactions that a miner is currently aware of (the "mempool"), each miner selects a subset that they want to include in a block. They usually select to include as many as are allowed (1MB), and select to create the most revenue for themselves (highest fee first). The miners are allowed to make any selection they want though, even to include no transactions at all (except the required coinbase transaction).
Block discovery:
Approximately every ten minutes, one of the miners succeeds at authoring a block. This block confirms the transactions that he previously selected by writing them to the blockchain (as long as this block ends up being part of the chain with the most work). This block in turn is relayed through the network to update all nodes of the new state of the network. The payment is considered settled at this point (with a high degree of confidence, although a few extra confirmations don't hurt).

There are multiple ways for a transaction to fail getting confirmed along the way:

The transaction is invalid, e.g. by spending unavailable money, being malformatted, being in conflict with a confirmed transaction, or the signature being incorrect. Nodes will not relay invalid transactions and if they already have them, drop them from their mempool.
The transaction doesn't get relayed. This happens e.g. when the transaction fee is below the minRelayTxFee of the sender's peers. The senders will not add such a transaction to their mempool and will not relay it.
The transaction doesn't get selected for block templates. If a transaction doesn't belong to the top 1MB by transaction fee rate, it will usually be delayed significantly, until the feerate comes down to its own, it is made invalid by a competing transaction, or a miner is incentivized in another way to include it in a block. Such transactions may time out eventually (How do transactions leave the memory pool?), but can remain valid indefinitely.


So, 1) there is a strict limit in the supply of blockspace with 1MB per ~ten minutes, and 2) Bitcoin transactions are useful in a number ways, it stands to reason that there will always be some sort of minimum bid to use blockspace (e.g. consolidation of low value unspent outputs, timestamping, colored coin applications, decentralized backups, poetry…). It follows that there will always be more demand for blockspace than supply and the price for blockspace will find some sort of balance at a fee rate where demand and supply match. Therefore, there will always be some unconfirmed transaction.

48786: <p>As far as I know, a miner begins creating a new block as soon as it receives a valid block from another miner. It then begins to construct and hash the next block on top of the block it just received by using all the transactions it has in its memory pool.</p>

<p>However, <a href="https://bitcoin.stackexchange.com/search?q=unconfirmed%20transaction">there are still some transactions that are not easily confirmed (or not confirmed at all), in the BitCoin</a>.</p>

<p>Can anyone explain to me why this can happen? Is it because of some transaction selection mechanism that the miners use? or is it because of the unreliability of the connecitivity between the nodes? or something else?</p>
 50934: <p>Transactions selected in mining blocks is not like a queue, where you wait your time and get to the front eventually.</p>

<p>Fees are not mandatory, but should be included in every transaction, if you have sent none, or low fees, you can still be selected (although it's highly unlikely), but the miner would be silly as they could just take the higher fee offered by someone else. Remember when you post a transaction you <em>offer</em> a fee.</p>

<p>If you owned a bakery and made 1000 loaves of bread a day, but had 1500 customers, would you sell them to someone offering $0.10 when other people are offering $1.00+.</p>
 5406: <p>The lifecycle of a transaction is the following:</p>

<ol>
<li>Transaction creation:<br>
A sender creates a transaction, he includes a list of recipients, determines which previous transaction outputs to spend, and signs it. The difference between output total and input total determines the transaction fee.</li>
<li>Relay:<br>
The sender submits the transaction to the Bitcoin network. 
He simply sends it to his peers, which in turn relay it to theirs. Eventually the transaction will be seen by everyone as it spreads through the network.</li>
<li>Transaction selection:<br>
From all transactions that a miner is currently aware of (the "mempool"), each miner selects a subset that they want to include in a block. They usually select to include as many as are allowed (1MB), and select to create the most revenue for themselves (highest fee first). The miners are allowed to make any selection they want though, even to include no transactions at all (except the required coinbase transaction).</li>
<li>Block discovery:<br>
Approximately every ten minutes, one of the miners succeeds at authoring a block. This block confirms the transactions that he previously selected by writing them to the blockchain (as long as this block ends up being part of the chain with the most work). This block in turn is relayed through the network to update all nodes of the new state of the network. The payment is considered settled at this point (with a high degree of confidence, although a few extra confirmations don't hurt).</li>
</ol>

<p>There are multiple ways for a transaction to fail getting confirmed along the way:</p>

<ol>
<li>The transaction is invalid, e.g. by spending unavailable money, being malformatted, being in conflict with a confirmed transaction, or the signature being incorrect. Nodes will not relay invalid transactions and if they already have them, drop them from their mempool.</li>
<li>The transaction doesn't get relayed. This happens e.g. when the transaction fee is below the <code>minRelayTxFee</code> of the sender's peers. The senders will not add such a transaction to their mempool and will not relay it.</li>
<li>The transaction doesn't get selected for block templates. If a transaction doesn't belong to the top 1MB by transaction fee rate, it will usually be delayed significantly, until the feerate comes down to its own, it is made invalid by a competing transaction, or a miner is incentivized in another way to include it in a block. Such transactions may time out eventually (<a href="https://bitcoin.stackexchange.com/q/46152/5406">How do transactions leave the memory pool?</a>), but can remain valid indefinitely.</li>
</ol>

<hr>

<p>So, 1) there is a strict limit in the supply of blockspace with 1MB per ~ten minutes, and 2) Bitcoin transactions are useful in a number ways, it stands to reason that there will always be some sort of minimum bid to use blockspace (e.g. consolidation of low value unspent outputs, timestamping, colored coin applications, decentralized backups, poetry…). It follows that there will always be more demand for blockspace than supply and the price for blockspace will find some sort of balance at a fee rate where demand and supply match. Therefore, there will always be some unconfirmed transaction.</p>
