Whenever we want a set of update operations to succeed or fail TOGETHER, we have to use transaction. If you move the code increasing the solve-count out of transaction, it is possible that Solution is created successfully while the count fails to be updated.