15 Jul, 2011, kiasyn wrote in the 21st comment:
Votes: 0
Rarva.Riendf said:
Quote
But if you're in the middle of crashing, the probability of your data being bad is much, much higher than if you are not in the middle of crashing.

If you are in the middle of crashing and you knew it, I think that means you know what kind of exception you have. So if it comes from data or something else. I do not think that have a DB or anything else to save data makes any difference.


Transactions.
15 Jul, 2011, quixadhal wrote in the 22nd comment:
Votes: 0
Transactions are a good way to prevent data corruption due to a failure in the middle of an operation. Another safeguard against bad data is foreign keys. If you know, for example, that your room terrain types can only be ROAD, WATER, GRASS, HILL, or FOREST, you can make a table of terrain types which your room table references as a constraint. So any attempt to modify or insert a record with some value NOT in the terrain type table will be rejected by the database itself.

By using foreign keys wherever you have fixed sets of possible values, you can help protect against buffer overflows and other in-memory corruption that doesn't always trigger a crash, but can screw up values that a plain file system will happily write out and read back in again. Even if you check and discard invalid values when reading, once it's been written the actual correct data is already lost.
15 Jul, 2011, Rarva.Riendf wrote in the 23rd comment:
Votes: 0
Quote
Even if you check and discard invalid values when reading, once it's been written the actual correct data is already lost.

But easily recoverable as backing up/comparing plain text file is really easy and do not need any real skills (and wont take more than 4 or 5 mins when using any source control program, all that for a scenario that is unlikely to happen anyway (I only had one memory corruption that led to wrong files in…many years). I only question the validity of putting 400hours to retrofit a diku. 400hours is a lot of time, that needs to be compared to 400hours to move your codebase to one that already use a database (and that is probably way more modern, and not using the stupid diku license as well).
15 Jul, 2011, David Haley wrote in the 24th comment:
Votes: 0
Rarva said:
If you are in the middle of crashing and you knew it, I think that means you know what kind of exception you have. So if it comes from data or something else.

You don't necessarily know. Look up signal handlers for seg faults, for example. (And also, look up how often people are told to *not* use them, even on this forum.)

Even if you did know, what would you do? The point is that when your program is so screwed up you're crashing, the probability of your data being garbage is much higher than when everything is normal.

And, of course, as Kiasyn pointed out, transactions help avoid saving corrupted data.

Rarva said:
400hours is a lot of time, that needs to be compared to 400hours to move your codebase to one that already use a database (and that is probably way more modern, and not using the stupid diku license as well).

400 hours is a lot of time, but moving to a whole new codebase is a lot more work than 400 hours.
15 Jul, 2011, plamzi wrote in the 25th comment:
Votes: 0
David Haley said:
Rarva said:
400hours is a lot of time, that needs to be compared to 400hours to move your codebase to one that already use a database (and that is probably way more modern, and not using the stupid diku license as well).

400 hours is a lot of time, but moving to a whole new codebase is a lot more work than 400 hours.


I love my good old CircleMUD. Played it in college and wanted to revive it, not to build a game from scratch. For all I know, the soul of the game is somewhere in the codebase. Dozens of people have invested hundreds of hours into the game and keeping their legacy is part of the project (I'm sure other MUDs are in the same position). And after the initial investment, there's no telling how many hours the db will save me, and how many solo projects it will make possible.

Regarding data corruption:
If you think restoring flat file backups is easy, then restoring database table backups is easier. I could "call RestoreBackup('Tuesday')" but I've never needed to do it on a global scale. Occasionally, I get power surges and was once forced to roll back the player object saves table to earlier in the day. But that's about it.
15 Jul, 2011, Rarva.Riendf wrote in the 26th comment:
Votes: 0
Well considering all you are saying I doubt your work can be used in other Circle/Diku or am I mistaken ?
I am guessing from what you are saying that as soon you update the database the game is changed, meaning you do not load everything at once in memory like common Diku does.

Quote
If you think restoring flat file backups is easy, then restoring database table backups is easier.

Different, I use CVS, so recovering any files is as easy as override/update from any version I want. I lose consistency (changing some item stats wont change it everywhere, but I do not want this behaviour anyway)
15 Jul, 2011, plamzi wrote in the 27th comment:
Votes: 0
Rarva.Riendf said:
Well considering all you are saying I doubt your work can be used in other Circle/Diku or am I mistaken ?


Most of the schema and a lot of the interface code can be re-used and I was thinking of packaging those up soon to put in the repository. Depending on how far your codebase is from Circle/Diku, you would have to modify accordingly, but it will take you a few dozen hours to do that vs. what I had to do.

Rarva.Riendf said:
I am guessing from what you are saying that as soon you update the database the game is changed, meaning you do not load everything at once in memory like common Diku does.


No, I'm not there yet. Some stuff like the help files is read from the db everytime it's used, so updating in the db is all you need to do (I do that in a browser). Some stuff, like the main quest table, is indexed by the game for fast access but can be re-indexed without a reboot. Most of the world is currently being loaded only at boot time and I'll add live refresh options to it depending on how often I need to tweak it without a boot. As it is, I reboot at least once every 48 hrs. due to other code additions so I don't hold uptime sacred…

And as for the hot boot option, there are a number of complications with it for my game. I've never used it successfully on the production server even though I've loaded it with all kinds of safety checks. I'm not crazy about players losing pets, or ending up facing a boss who is suddenly again at full health, or losing keys to a zone they've spent hours collecting, or seeing a roaming mobile disappear… I'd much rather schedule a reboot.
15 Jul, 2011, JohnnyStarr wrote in the 28th comment:
Votes: 0
yes.
15 Jul, 2011, Rarva.Riendf wrote in the 29th comment:
Votes: 0
Oh very nice then. I thought you would have gone all the way already making it too hard to use for someone who is stuck with olc.
15 Jul, 2011, Runter wrote in the 30th comment:
Votes: 0
Rarva.Riendf said:
Runter said:
tl;dr

The point of a database is the query. […]


Everything you mentionned though is very easy to do in bash with a simple grep. In usually even less character typed than a db query, and without having to know anything else than a directory. A DB has some use when something is big enough or 'generic' enough. And as I said a DB in a mud is really nice if you already has it when you start. Retrofitting one…less so.

I will add a great benefit of having a DB: you can scrap your engine way more easily as well. So if you want to move away from Diku it is way easier.


I think you completely missed the point, but whatever. If you're not going to be convinced that using a database is a good thing here you'll never be convinced. Your proposed solution is such an OS dependent hack that I don't even want to entertainment it.

I just worry that readers on the fence might not understand how you could so easily hand wave this away. For those readers I say this: Do be very careful about advice you get on a hobbyist site devoted to practices that were appropriate in 1980. Being a hobbyist doesn't mean you have to do things poorly. And fwiw, doing things right usually is just easier in the long run.
15 Jul, 2011, Vigud wrote in the 31st comment:
Votes: 0
MUDs were appropriate in 1980.
15 Jul, 2011, plamzi wrote in the 32nd comment:
Votes: 0
Rarva.Riendf said:
Oh very nice then. I thought you would have gone all the way already making it too hard to use for someone who is stuck with olc.


Actually, I have OLC save to SQL funcs to share, too. The long-term plan is to build new zones using a web UI but OLC will always be very useful for in-game tweaks. Give me a few days and I'll post all I've got.
15 Jul, 2011, Runter wrote in the 33rd comment:
Votes: 0
Vigud said:
MUDs were appropriate in 1980.


It's almost like you're trying to make a point, but just not quite getting there. So I'll wait til you actually make one to reply.
15 Jul, 2011, Cratylus wrote in the 34th comment:
Votes: 0
I think that "You don't need X, just use bash and grep" is my new thing I'll say.
15 Jul, 2011, Rarva.Riendf wrote in the 35th comment:
Votes: 0
And I think you missed mine. I am all in for using database over flat files. But you always have to pounder time put in migrating a flat file system to a database one.
If you stay at a hobbyist level, it may not worth it. A database is better for sure and I never said the contrary.
And as you said 'a database is better in the long run' long run is the keyword. 400 hours is alot of time, and to recoup them you will need to make an extensive use of your database.
It is like the time you would need to learn how to use awk/sed/bash compared than limit yourself to the tools provided by notepad++ to search/replace etc.
Let say you have one nail to plant and no hammer but a rock.
You could drive to the store get a hammer come back.
Using a rock you could have done it before you even started your engine.
All this depends on how frequent you have a nail to plant.
This is a better advice than 'you always have to get a hammer because it is a better tool for the job'. Yes it is…but no it is not always the best solution either. Especially in IT.

You can even check some of my post where I advocate the use of a database to someone instead of using flatfiles…on a NEW project.
15 Jul, 2011, Lyanic wrote in the 36th comment:
Votes: 0
World persistence…
16 Jul, 2011, Tyche wrote in the 37th comment:
Votes: 0
Standalone Relational Database Y/N?
Maybe.
It'd be a step back to the 80's, if your mud server already implements an object-oriented database.
A step forward if you're using a typical Diku.
MySQL will frequently corrupt databases in power outages, if you're using MyISAM as the back end.
That's the penalty you pay for speed, poor ACID.
Why not use something more reliable like SQLite, DB2 or Postgres?
16 Jul, 2011, plamzi wrote in the 38th comment:
Votes: 0
Tyche said:
Standalone Relational Database Y/N?
Maybe.
It'd be a step back to the 80's, if your mud server already implements an object-oriented database.
A step forward if you're using a typical Diku.
MySQL will frequently corrupt databases in power outages, if you're using MyISAM as the back end.
That's the penalty you pay for speed, poor ACID.
Why not use something more reliable like SQLite, DB2 or Postgres?


Because speed is important, a UPS is $40, and having full-blown features, an API for every language, and nice clients for every OS is sweet.
16 Jul, 2011, Runter wrote in the 39th comment:
Votes: 0
Tyche said:
Standalone Relational Database Y/N?
Maybe.
It'd be a step back to the 80's, if your mud server already implements an object-oriented database.
A step forward if you're using a typical Diku.
MySQL will frequently corrupt databases in power outages, if you're using MyISAM as the back end.
That's the penalty you pay for speed, poor ACID.
Why not use something more reliable like SQLite, DB2 or Postgres?


I prefer postgres of those three options, actually.
16 Jul, 2011, Rarva.Riendf wrote in the 40th comment:
Votes: 0
Better to use the one that already runs. It is not like the function a mud needs would not be available on any modern DB. I have a phbb forum backed up by mysql so I would use mysql.
would it be something else it is not that hard to modify change of db driver.
20.0/81