atomicAdd inbetween dispatches of two compute shaders


I have looped compute shader dispatches. Between 2 reruns of the same compute shader, A, i have a housekeeping compute shader that resets values.

Compute shader A (use atomic add to increment x)
Compute shader B (use x to set up some variables, reset x to 0)
Compute shader A (rerun of compute shader A, use atomic add to increment x)

However, i find that on the second rerun of A, x is not necessarily set to 0. It’s holding on to some previous values. Why? Even if i put a glMemoryBarrier() after compute shader A, and before runnign compute shader B, that does not solve the problem. Ideas?