MySQL Storage Engine API Gotcha #42

(Filling 1 through 41 is an exercise left to the reader… I just like the number 42)

handler::info can be called on a handler that has never had ::exeternal_lock called. So if you rely on a call to handler::external_lock to set up something (e.g. a pointer to a transaction object), you may explode in a heap.

See: Bug#26793

Backup and Recovery (the book)

A little while ago now, I did some tech reviewing of a book called Backup & Recovery… specifically MySQL related things (and MySQL Cluster). Curtis was kind enough to send me a copy of the book as well – and I’ve been reading the rest of it bits at a time since I got it.

I’m rather impressed… it gives a good mix of overview and digging deeper on just about every way to back up and recover systems. It also discusses several products that I didn’t know about (and have partly investigated now because of it).

It also has good sections on process: as in how to decide what to backup, encouraging the use of checklists and all that. Heck… recently when doing a restore I realised I never backed up /boot (annoying, not catastrophic… as I know my way around).

I recommend getting a copy of it if you need to back up and restore systems and don’t know everything already.

MythTV and poor quality DVB reception

So… I’ve been getting really poor DVB reception recently. I mean bad…. as in next to nothing is getting recorded… and anything HD is more noise than image (or sound).

A symptom of this is that the mythbackend (and indeed frontend) can crash when processing really bad MPEG2 (recording) files. So, if you get poor reception and crashing frontend/backend.. this is probably why.

Even loading the list of recordings from MythWeb can be problematic (as it has to generate the preview image).

Just something to watch out for… hopefully i’ll track it down a bit and be able to file a sensible bug report.

Another positive review for Practical MythTV!

Over at fosswire.com, there’s a review of Practical MythTV. Here the copy of the book was provided by our publisher, Apress – who are getting some copies out there to people to look at and review (and the reviews are positive which is great news for us!).

You can get Practical MythTV from Amazon for under $20USD at the moment… which is pretty cool.

reading maildirs…. fast…

So, for a side project i’m hacking on, i’m wanting to read in Maildirs really fast (and then pump them into something else… for current purposes I’m just putting everything in one file.. getting the read speed up is of current importance).

I’ve done a bit of experimenting and my current method (which seems to be as fast as any):

  1. read the directory (cur)
  2. sort by inode number
  3. foreach 1000 inodes:
    1. sort by start block number
    2. read message

This makes a couple of assumptions:

  • sequential inode numbers are close to each other on disk (making stat(2) cheaper)
  • mail messages are small… likely to be in 1 extent, so start block is a good metric for locality.

Oh, some of this is specific to XFS… which is what I care about (and it turns out you don’t need to be root to get an extents list for a file on XFS).

cell phone reception….

Watching an SBS show from whenever… a guy living in the middle of the desert in Oman gets good phone reception. Hrrm… how are we with that here?

Evolution import VCF possibly the slowest thing in the world…

Waiting and waiting and waiting and waiting. It’s only a few hundred cards in there…. urrggh.

Eat My Data: @ luv Tuesday 3rd July

Tomorrow night (that’s Tuesday the 3rd of July) I’m speaking at LUV (Linux Users of Victoria). I’m presenting “Eat My Data: How Everybody Gets File I/O Wrong“.

This is another one of my (possibly futile) attempts to get people to care more about data integrity when writing software – and the less futile attempt to make users cry*.

* over lost data, not spilt milk.

UPDATE: date is Tuesday the 3rd . Turns out I can’t use /usr/bin/cal

Another favourable Practical MythTV Book Review

Over at mythpvr.com, there’s a review of Practical MythTV. It’s good to see the book being well received.

ndb_mgm pr0n

ndb_mgm> all report MemoryUsage

Node 1: Data usage is 11%(632 32K pages of total 5440)
Node 1: Index usage is 22%(578 8K pages of total 2592)
Node 2: Data usage is 61%(3331 32K pages of total 5440)
Node 2: Index usage is 40%(1039 8K pages of total 2592)
ndb_mgm>

Oh, and that’s coming from saved command history.

(as seen when upgrading my cluster here to mysql-5.1.19 ndb-6.2.3 – i.e. MySQL Cluster Carrier Grade Edition – i.e. the -telco tree)

Things that have recently stalled….

  • compressed backup patch
    • actually works rather well… and restoring from compressed backup too.
    • need to modify the rate-limiting code though… may as well rate limit the writing of the *compressed* data stream… otherwise the option isn’t nearly as useful
  • compressed LCP patch
    • well… the *restoring* of compressed LCPs…. can write them
  • working out exactly what more information I want out of the linux memory manager to find out what kswapd is really doing (and the patch that exports the right info)
  • re-jigging my procmail filters for commits@lists.mysql.com
  • fixing up my offlineimap patch and getting it in upstream
  • disk pre-allocation for MythTV recordings
  • buying workstation
  • unpacking the last few boxes around the house
  • finishing this list.

Run Backup, Run!

Over the past N weeks/couple of months, we’ve been making a number of improvements to how backups are done in MySQL Cluster.

Once you get to large data sets, you start to really care about how long a backup takes.

Traditionally, MySQL Cluster has been in-memory only. The way to back this up is to just write from memory to disk (rate limited) and synchronised across the cluster.  Since memory is really fast (compared to the rate we’re writing out to disk) – never had a problem.

In MySQL 5.1 (and Cluster Carrier Grade Edition- CGE), disk based attributes are supported. This means that a row has both in memory and disk based parts.  As we all (should) know, disk seeks take a very long time. We don’t want to seek.

So, at some point recently we changed the scanning order from in-memory order (which previously made perfect sense) to on disk order. Randomly seeking through RAM is much cheaper than all the disk seeks. This greatly improved backup performance.

We also did some read-ahead work, which again, greatly improved performance.

Today, I see mail from Jonas about changing the way we read tuples for backup (and LCP) to make it even more efficient (READ_PACKED). This should also reduce CPU usage for LCP/Backup… which is a casual issue. I should really take the time to look closely at this and review.

I also wrote a patch to the code in NDB that writes files to disk to write a compressed gzio stream instead of an uncompressed one. This happens in a different thread, so potentially using one of those CPU cores that ndb wouldn’t otherwise use… and also dramatically reducing the amount of data written to disk…. this patch isn’t in any tree yet, and I’ve yet to try it with the READ_PACKED patch, which together should work rather well.

I also need to grab Brian at some point and find out why azio (as used by the ARCHIVE engine) doesn’t work the same way as gzio for basic stream writing…

puzzling dot org : Finally feminism, suggested questions

So, Mary a little while ago found Finally, A Feminism 101 Blog (and she suggested some more questions for it). It turns out to be a pretty good read and summary… one well worth keeping around to at the very least point people to.  Oh, I should post more (got about 10 good blogging ideas in the brain) but I should really stop reading interesting RSS and get back to work…

Percent geekiness is not gender specific…

So, Pia is 80% geek. That area in the brain that causes you to take internet quizzes got activated and I went and did it…. casually surprised that the first question was “what gender are you”.  After being geeky enough to debate one of the questions (the email one… you should get more points to be okay with not going for mail for a while because you instead batch it up so that you loose less time to context switching), I did the “so what if I answered this quiz as a woman”. It turns out, no difference – still the same percentage of geek.

So why is the question there? Gah… the other part of my brain (the part responsible for optimisation) is firing intensely. gah.

Somebody should blog…

So, for whatever reason, at about 2am this morning I was finding out what showed up when you googled linux.conf.au for sites in Swedish.

(actually… I do know why.. I was waiting for a a cluster to start so i could run a test)

Somebody should blog (in Swedish) about how awesome the upcoming linux.conf.au in January 2008 (in Melbourne) is coming along.

Melbourne will be much warmer and sunnier than Sweden in January. Promise.

My Top 5 Wishlist for MySQL

I’m going and stealing Jay’s idea (who stole it off Brian Duff… but his was for Oracle so obviously doesn’t count :)

So, my five wishes for MySQL Are:

5. Six-monthly release cycles

Getting a release out there takes way too long. There’s a variety of reasons, but seeing the amazing success of other free software projects taking the shorter release cycle, with each release not being too ambitious, I’m pretty convinced.

Although I think our increased use of pushbuild has helped immensely with the general quality of the tree, there’s a lot more that can be done…

4. Much more in depth automated testing

For MySQL Cluster we have (in parts) an insanely detailed test suite… lots of error injection to test failure (or, more importantly, recovery), verifying data, transactional consistency etc. Also, tests that run multiple connections, threads, simultaneous transactions and test the results programatically (comparing strings is generally not very useful… even when it comes to something as simple as IPv4 or IPv6 address!).

Part of getting here is the SoC project I’m mentoring… which should have an output of some utilities for helping write better tests (rather like we have for NDB… but for SQL instead of NDB API).

3. Sane build system

Something that not just the build team knows how to produce a binary that’s released. The other side of this is a way to build your local working tree (and test it) on BLAH platform, without pushing.

3.5. (yes, i have a 3.5)

Kill HPUX. There’s a reason the name sounds like a disease.

2. Increased liberal use of asserts

This is just a wish from a bug I’ve been tracking down where the code to build an I_S table didn’t check that we opened all the tables successfully before calling handler::info()… which promptly goes fooey because the handler hasn’t opened the table. Luckily here it’s ended in a crash… IMNSHO it’s better to bail out on an assert than possibly return crap to the user…

1. Pluggable data dictionary

There are so many oddities and “bugs” around related to the casually strange mix of data dictionaries around the MySQL Server (and Federated, NDB, InnoDB, Falcon etc) that we could do a lot better if we had a “Virtual Data Dictionary Layer”… where engines who really do have a reason to not be simple (e.g. NDB) could plug in and the MySQL Server could get all the metadata consistently from the cluster (with out own form of sane-ish caching).

This would also solve the online ALTER TABLE frm consistency problem with engines that may roll back the alter table on crash recovery (or not support querying the index until it has finished being built).

Perhaps this is something for either the next engine summit or dev conf…

It’s here! It’s here!

So, I hear you ask (ask dagnammit!), what does a MySQL Cluster hacker do when not hacking MySQL Cluster?

Well,

Today, a box arrived:

dsc_7868.JPG

I eagerly opened the box… eager for what was inside:

dsc_7869.JPG

Hrrm… this does look promising! Quickly I turned it all up the right way:

dsc_7871.JPG

It’s here! It’s here! Only about a month after Michael got his copies! Gah international shipping (and moving addresses) can be casually annoying sometimes. But anyway, it’s here, it looks sweet and now I can go set up a menu option to automatically transcode MythTV recordings to a good format for the iPod. Brilliant!

Of course, this is about how many copies you should go and buy:

dsc_7874.JPG

So kids, go order your copy of Practical MythTV today! You too, like me, can then go “hrrm… my MythTV MySQL database isn’t Clustery enough… perhaps I should run it on NDB”. :)

You should also go and get a copy of the MySQL Cluster Certification Study Guide as I have writing in it too! Yes, this past year has kept me busy!