When a slider stops locking, the mechanism is usually fine. The panel moved.
A sliding door lock is a hook driven out of the panel edge into a slotted plate on the jamb, called the keeper. The tolerance between them is a few millimetres. They were aligned when the door hung square.
As rollers wear, the panel settles. The hook drops with it. The keeper, bolted to the fixed frame, does not. Once they are out of register the hook hits the edge of the slot instead of entering it, and the door stops locking.
Here is the thirty-second test: close the door, lift the panel slightly by the handle, and try the lock. If it suddenly engages, nothing is wrong with your lock. Fitting a new one will miss by exactly the same margin.
A patio slider is a well-known entry point, and one that will not latch offers no resistance at all. There are two knock-on effects people do not expect either.
The latch is what pulls the panel tight against its weatherstripping. Without that pressure you get air infiltration, water intrusion in wind-driven rain, and insects finding the gap. And some insurance considerations assume secured, operable openings, so a door that cannot be locked is better resolved before it becomes a question during a claim.
While you wait: a cut broom handle or dowel laid in the lower track behind the panel stops it sliding. It is a real deterrent and costs nothing, though it does not substitute for a working lock.
If we are replacing hardware anyway, coastal homeowners are usually better served by solid brass internals rather than the plated pot metal many doors shipped with. Pot metal fails at the plating, then corrodes from inside. Brass simply keeps working. The price difference is small and the service life difference is not.
Free onsite estimates, same-day repairs, every day 7am-9pm.