|
Blogs
My colleagues from the development know that too well as I'm asking for documentation and notes all the time for everything. BACK IN TIMELast week I got this message and I believe it will be interesting for many MaxDB users "out there". Customer:
Ok, what's that about? The server got rebooted, and now the database is back at a previous state? When I read the description of the customer I already suspected what turned out to be the actual reason for the loss of data. To verify my assumption I only needed to check the DBM.PRT file. This is what I found:
There is was: the log writer of the database had been turned off. The short answer is: If you now ask yourself "Wait a minute - what have savepoints to do with the log writer and why does this cause a huge loss of data?" then you may want to read on. THE CONVERTER - KEEPER OF THE DATABASE STATES... A LITTLE EXCURSE...Ok, the first thing to understand here is the way MaxDB stores and retrieves data to and from the disks. Unlike most other databases, MaxDB does NOT store data at s specific physical location. One advantage of this is that by writing out data to the disks MaxDB automatically can even out the filling of the data volumes and thereby guarantees an equal distribution of I/O over all data volumes. Of course something needs to keep track of this so that the database can actually find the correct location of each page. This something is the so called converter. You put a logical page number into it and get a physical block location out (or vice versa). Seen from that angle, the converter holds the state of the database at all times. "But, wait a minute, where is the information of the converter stored?" Good question! Since the converter is so utterly important to the database (without it all the pages in the data volumes are just nonsense), MaxDB needs to save it regularly, so that it's there the next time the database is started. STILL AWAKE?Did you notice something? We have data volumes full of pages that can only be brought into context and meaning by the converter. And this converter itself is also stored in the same cryptic way in the data volumes. "How the heck can MaxDB figure out which pages belong to the converter when it starts up?" Again, good question! Unlike usual data pages, converter pages on disk do have pointers to physical locations to the other converter pages, enabling MaxDB to find and read all converter pages before having the converter available for the mapping of logical to physical pages. Now, the last missing link, the one to the root page of the converter comes in: The restart record. This is a 'magic' data structure that is always located in the first block of the first data volume. (Just for those super-techies among you readers: it's the crConvRootBA value you see in x_diagnose. Fine, to summarize:
So whenever the converter is written down to the data volumes, this link to the converter root needs to be updated. The restart records have to point to the new converter root. By the way: this is precisely the way that SNAPSHOTS work in MaxDB. UPPS!Yes, here we have it. During the month of work where the database was running, there seem to have been no SAVEPOINT. Isn't a SAVEPOINT expected to happen AT LEAST every 600 seconds (or in whatever interval is configured by the _RESTART_TIME parameter)? DOUBLE UUPS!By disabling the log writer, the customer effectively turned off the automatic writing of savepoints! Of course he could have triggered savepoints manually or by taking backups, creating indexes or by just stopping the database via a DB_OFFLINE. Unfortunately the customer decided, that the server needed a reboot and just ran "shutdown -r now". The outcome of this was that the customer simply lost a month worth of work and there was no technical option to rescue his data. WHAT A BAD MALICIOUS FUNCTION IS THAT?One could of course argue that such a function should have no place in a DBMS, because one of the main functions of DBMS is to keep the users data safe. It's a benchmark feature that allows certain performance tests without the effect of log writing. Also, there are specific situations where you can greatly benefit from this function. All in all it's just another feature that can be used correctly or the wrong way. The only morale here is: understand what a command or feature does before using it! LinksImportant concepts like the CONVERTER are of course explained and documented, so here is a list of links to the relevant resources (for those of you that still cannot get enough of tech-talking): No-Reorganization Principle: Data Storage Without I/O Bottlenecks SAP support note #869267 - FAQ: MaxDB LOG area, 35 + 36
A LITTLE ADVERTISINGI was asked to blog about the TechEd Session I'm going to deliver, so here it is: If you're not already booked for October 27-29 this year and you happen to stay in Vienna/Austria and you keep asking yourself what to do ... then get your ticket for SAP TechED 2009 and make sure to attend my MaxDB Session
Lars Breddemann
| |||||||||||||||||||||||||