I am looking for information about the following lock:

I have been using a similar lock for some time now, but the inner mechanism stopped working in such a way that when I try to open the lock, those two balls inside are not retracting back to their unlock position. They stay loose, so only if I shake the lock they might get into their place and the shackle can be released from the lock.
It made me wonder, how this mechanism works? what is supposed to pull those two little balls inside when I unlock, and what's pushing them back out when it's being locked?
I couldn't figure it only from this picture alone.
Would really appreciate your kind explanation about it.
P.S.
I don't even know if this mechanism has a specific name I could look for.
Thank you!