For the first time since 2004, a country other than China has won an Olympic table tennis event, as Japan pulled the upset in a thriller in the new event of mixed doubles.