Transaction safe economy?

Discussion in 'Bukkit Help' started by phrstbrn, Jul 17, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    phrstbrn

    Are there any economy plugins which are fully transaction safe? Most economy plugins don't seem to be.

    What I mean is, if I call Account.add(player, money) in two separate threads, most economy plugins will fail to record the transactions correctly, and one of the two transactions will probably get lost. Ideally I'd like something that can do this without a global lock either. I know this is possible by using a transaction safe db (ideal) or using SQL table locks (less ideal), but none of the plugins seem to do this.

    Since none of them are transaction safe, that means I need to do all transactions in the main thread otherwise there is a potential to lose transactions. Say I want to send money to 100 people via some plugin. Each transaction is really, really slow, 3-6 ms. That's 10-30% of a tick just blocking on one transaction. Not a lot of CPU, just I/O blocking. That's awful. So, ideally I would want to do it in a separate thread so I/O doesn't block. Unfortunately, since none of them are transaction safe, I can't do this without risking losing data.

    If the answer is "no" (which I suspect is the answer), then it looks like I'm writing a transaction safe economy plugin.
     
  2. Offline

    GunfighterJ

    I am working on a MySQL based economy for a private server right now, but plan to release it to the public once testing has been completed. It works off of caching player's accounts when they log in, loading the data to their account asynchronously in a pre login event. All transactions are done in the main thread as they should take very little time to execute a change in a map. Periodically a thread is called that grabs all the stored data, checks for any transaction changes, then queries MySQL to store the data. This keeps overhead down and the amount of queries to a minimum, while still making sure data is kept without it being lost.

    It's early in development as I have just started it a couple days ago, but I hope to have something publicly available in the next few weeks.
     
  3. Offline

    phrstbrn

    That sounds interesting, and solves half the performance issue, but I'm still looking for something that's transaction safe. I don't care how long the SQL takes, just that I can safely call it from another thread and not worry that my transactions will get lost.
     
  4. Offline

    GunfighterJ

    Most of the API will be synchronized methods, which should prevent losses.
     
  5. Offline

    phrstbrn

    Caching the values means it's not transaction safe, even if you add the appropriate synchronization. Somebody pulls the power cord and poof my transactions are gone. I don't care about speed, I just want them to be transaction safe, and and able to be called asynchronously.

    I think the answer is "it doesn't exist", which is a shame.
     
Thread Status:
Not open for further replies.

Share This Page