mm201 / pkmn-classic-framework

Pokémon application logic for Generation IV and V, including servers
http://pkmnclassic.net/
Other
219 stars 43 forks source link

Apparently some trades don't get committed to the database #112

Closed mm201 closed 2 years ago

mm201 commented 2 years ago

This seems to be a rare issue but I've received two reports of it so far, one of which I was able to confirm in IIS logs:

Sometimes, when you perform a trade, the original offer remains available and someone else (or you again) can trade for it again, creating a clone. My logs confirm that an exchange_finish.asp request has been received and a normal response sent, but the database isn't updated.

Ideas:

  1. The request was bad and exchange_finish.asp should've given an error response but didn't.
  2. A database transaction got inappropriately rolled back after the response was sent.

Next maintenance window, I will update both mariadb and the MySQL connector and see if that makes a difference.

mm201 commented 2 years ago

Reviewing my GTS code as I work on record locking, it's apparent that there's some other places where transactionality isn't perfectly honoured, which could also allow for situations like this to arise in very close races.

I was hoping I wouldn't have to wrap mysql transactions.

mm201 commented 2 years ago

I replicated the issue in my dev environment and discovered that sometimes when exchange_finish.asp returns 00 00, the game will happily finish the trade instead of Bluescreening as it should.