In this paper we study a single-server Markovian retrial queueing system with non-reliable server and threshold-based recovery policy. The arrived customer finding a free server either gets service immediately or joins a retrial queue. The customer at the head of the retrial queue is allowed to retry for service. When the server is busy, it is subject to breakdowns. In a failed state the server can be repaired with respect to the threshold policy: the repair starts when the number of customers in the system reaches a fixed threshold level. Using a matrix-analytic approach we perform a stationary analysis of the system. The optimization problem with respect to the average cost criterion is studied. We derive expressions for the Laplace transforms of the waiting time. The problem of estimation and confidence interval construction for the fully observable system is studied as well.