Example (invariant distribution in random walk with retaining barrier)
Consider the random walk on $\Z_+$ with a drift towards the origin and a retaining barrier at 0: $$ \begin{cases} P(x,x+1) = p, &x\geq 1, \\ P(x,x-1) = q \equiv 1-p, &x\geq 1, \\ P(0,1) = p, \\ P(0,0) = q, \end{cases} $$ with $p<q$.
The invariance equations are $$ \begin{cases} \pi_i = p\pi_{i-1} + q\pi_{i+1}, &i\geq 1 \\ \pi_0 = q\pi_0 + q\pi_1. \end{cases} $$ Solving, the first equation gives a general solution $$ \begin{align*} \pi_i = A + B\left(\frac{p}{q}\right)^i, \quad i\geq 0 \end{align*} $$ and the second equation yields $A=0$, so $$ \begin{align*} \pi_i = B\left(\frac{p}{q}\right)^i, \quad i\geq 0 \end{align*} $$ We then normalise this to get $$ \begin{align*} \pi_i = \left(1-\frac{p}{q}\right)\left(\frac{p}{q}\right)^i, \quad i\geq 0 \end{align*} $$ which is an invariant distribution. The chain is therefore positive recurrent.