thebigbear wrote: I thought computer science had gone beyond this point.
Sorry if this is a bit of a long time to respond to an inactive thread, but I just wanted to have down a tiny bit of the CS behind why this works the way it does. Mostly because everybody will experience it some time, and I think it's worthwhile to have some idea why it works the way it does. I'll keep it as basic as possible because A) the weeds and details aren't relevant to most people and B) I don't want to give inaccurate information because I'm not an admin and don't work with the server.
Everything you do during a session is stored in the server's RAM. Specifically, your session has a
thread spun out just for it, and that thread will terminate either when your session ends or the server is shut down/crashes.
Communicating with that RAM is pretty quick, especially compared to communicating with the permanent storage on disk. I/O with the disk might as well take an eternity in comparison, and is to be avoided at all costs. If every action was immediately written to disk, the server would spend all its time interacting with storage and very little actually running the game. Bigger games are able to get around this by spending a lot more on their server infrastructure. Illarion e.V. is a nonprofit, which doesn't really make it easy to throw money at hardware.
Many things can cause a server crash. Server crashes are inevitable to an extent because software cannot be perfect. Unknown bugs in the code could cause the server to crash unexpectedly, just like they cause your browser, the game client, Office products, etc. to randomly crash. The OS could crash for reasons beyond our control, bringing down the whole system. Too many players online at once will use up a lot of RAM (keep track of all those threads) and a lot of processor power. A power outage at the physical site of the server could bring it down. Every server will have downtime, developers and IT professionals just try to minimize that downtime as best as possible.
When your session ends under normal circumstances (Disconnect, log out, kicked, etc.) the state of your thread is written to the database, which is on disk. This happens pretty infrequently in the scheme of things, so the cost of writing to disk is no big deal.
When your session ends because the server crashed, nothing can be saved to the DB. This is for a pretty straightforward reason: a program that is crashing is generally unable to execute any code. It is only really capable of being terminated, or of causing the system as a whole to shut down.
Potential server changes have been discussed to mitigate the problem of a server crash when there are very long lived threads, like after a 3+ hour session is lost. Some viable possibilities, which haven't been agreed to or implemented but are possible might be like these:
A) The server automatically saves state every X minutes/hours. This is doable, although saving the data for every user all at once could possibly result in server hang-ups whenever it happened. Like the game freezing for a few seconds whenever it happens. Perhaps a timer tracking the session length could trigger a save for your session every X minutes of the active session.
B) Allow users control over when their session is saved. This is actually pretty dangerous to do, because it has the potential for abuse. If I can find a way to make the server save my progress a thousand times a second, I can probably crash the server whenever I want.
C) Have the scripts trigger a save every time some type of special action is performed. Save after acquiring a pure element, giant map, etc. If the player is able to trigger this every time they pick up the element, it has a lot of room for abuse in the same way B would.
TL;DR Your session is only saved at logout because it prevents the server from being incredibly slow, crashing, and costing a lot more money to run. Also, the server is worked on by essentially just Vilarion. Crashes will happen, although they are as rare as possible. However, any good gamer should live by the motto "Save early; save often" anyway. If you're afraid of losing progress, just relog every hour or less.