I had a very similar problem a couple of months ago..
Turns out they (Dealer, Mazda Regional, Mazda USA AND Mazda Japan) have absolutely no idea what caused it, so they replaced the knock sensor and the ENTIRE EXHAUST MANIFOLD. Pretty crazy.
I'd like to note that Mazda had to hire translators...