Consider an ideal gas in a cylindrical container in a gravitational field, with a piston on top pushing down by gravity. The piston has some locking mechanism that locks it in place if it is displaced upwards enough that the temperature of the gas is some $1>>\epsilon>0$. If we wait long enough, enough particles will line up due to their random motion and push the piston upwards. We can make the piston arbitrarily thin and arbitrarily heavy. Eventually it will lock in some final top position and some arbitrarily small portion of kinetic energy is left in the gas. Since we can make the volume change arbitrarily small, while momentum phase space goes to zero, the entropy must have decreased in this process, but that cant happen, so what is wrong with this reasoning?
The system you design is not closed and cannot be closed to the volume your are postulating.
Entropy increases or stays constant is a statement involving the whole package, pistons containers and all. Entropy is lost through black body radiation, which cannot be isolated but has to be counted, and the thermal properties of the container and piston.
You are describing how pistons may fail over time by relaxation, but no problem with entropy and the second law.
The answer relies on the crucial fact that there are no irreversible processes, otherwise we could make the lock permanent and would have a 100% efficient heat engine. Read this question (but not the wrong upvoted answer) for further details.
So when the lock has locked it, it will eventually fluctuate into an unlocked state, this will repeat until most likely it heats up and reaches thermal equilibrium. My guess is that at this point the probability that the piston is in the high position after a long time approaches the same as that of the system (minus the thermal energy of the lock) without a lock.