Essential Slick: a review

I read the HTML version, as I’m reading it on a Macbook, and HTML just seemed the most generic. I have tried Slick tutorials, for example, and the Hello, Slick example projects – only to have them fail out of the box or simply not working, with no clear explanations. I’m pleased to report that this has not been the case with Essential Slick – the code has worked very well, and been explained clearly. While in early access, there are a few minor problems – for example, in the book’s source code they use durations early on without specifically including them or describing them.

Essential Slick” is a book by Richard Dallaway and Jonathan Ferguson, published on underscore.io. It’s designed to be a compact guide to Slick, a database-access library for Scala, and succeeds admirably in its goal, even in early-access form.

The book is very easy to read; it’s published in multiple forms (epub, HTML, and PDF). I chose to read the HTML version, as I’m reading it on a Macbook, and HTML just seemed the most generic.

However, the content is the most important part.

I’ve tried to play with database access in Scala; I usually end up working with a model written in Java, accessed via Hibernate, because of familiarity with Hibernate and, more importantly, because the documentation for various Scala database access mechanisms is simply inaccessible to me – generally being unclear or simply not working.

I have tried Slick tutorials, for example, and the Hello, Slick example projects – only to have them fail out of the box or simply not working, without clear explanations.

I’m pleased to report that this has not been the case with Essential Slick – the code has worked very well, and been explained clearly.

While in early access, there are a few minor problems – for example, in the book’s source code they use durations early on without specifically including them or describing them. (The example project, however, does include all required types.) Likewise, the output from the example project is slightly different (being far less verbose) than the book’s project code.

These are not real problems, at all; durations are fairly obvious, and the debug output is actually very informative. It just wasn’t entirely expected.

The exercises are useful, and are accompanied by explanations of various problems you might encounter; this is very newbie-friendly (as one would hope from an introductory text) and therefore targets its audience perfectly.

Topics proceeding through the book include selection, modeling, and combining actions (i.e., building complex transactions). Along the way, some assumption of Scala knowledge is expected, but it’s not written arrogantly – Scala beginners can expect to understand the content.

By the end of the book, even in early access form, readers can expect to have functional and useful knowledge on Slick, and can expect to be able to write workable applications leveraging relational databases and Scala.

I’ve found the book to be highly informative – and, if you’re using Slick, necessary, compared to the other Slick resources out there. Highly recommended.

MySQL log sequence error

I just had the most fun time ever with MySQL backing an instance of WordPress. I’m writing up what happened and how I “fixed” it – note the quotes – just so others are aware of it. Maybe someone has insight into how it happened or has a better idea of how to fix it for the future.

The Errors

The timeline for the error stretches back months, to an ill-advised VPS update on my part back in August or September, I think.

I use RamNode as a hosting provider; I chose Fedora as my OS (because it’s Fedora, and I like Fedora.) However, it’s limited to Fedora 20. I wanted to run something more current (since Fedora 20’s a little bit outdated) so I went through the update process — which broke everything catastrophically.

RamNode justified itself, by providing me with a system image backup (which isn’t, by the way, their responsibility – they just came through anyway. I highly recommend RamNode.) So I rebuilt the image. I copied all of the WordPress files back into place, and did the same for the MySQL database directories.

The truth is: it was MariaDB, not MySQL. All of the commands are the same and the database files are binary-compatible; I prefer MariaDB for social reasons. By the end of the adventure, though, I was using the community version of MySQL instead of MariaDB just in case it was something about the MariaDB release. Voodoo debugging on my part. 🙁

I got a few log sequence number errors there, but removing the old log files cleared that up, or so I figured. At the very least, I didn’t see any problems.

The “Fix”

Now let’s zoom up to November. My wife told me her site was performing very poorly, and since her stuff’s pretty important to me (it’s hers!) I took a look at the logs to try to figure out what was happening to the database.

It turns out that the log sequence problem was back, with a vengeance. Now every database interaction was firing off dozens of log sequence errors, resulting in the database being killed and restarted. No wonder her site was performing poorly.

I removed the log files again (to try to get the log sequence reset, because ignorance) and that didn’t fix anything; I tried to do a mysqldump and it couldn’t even read the data. I’d get errors trying to make a backup.

This was not good.

I then took a copy of the backup (made via tar cvzf) to a virtual machine (through VirtualBox, on a Fedora image). Here’s the odd thing: the machine in VirtualBox had no problem reading the database. Record counts were fine, all of the data was there.

I didn’t alter the files at all – but took the opportunity to dump the data (via mysqldump again, this time getting a valid SQL dump.)

I went back to the VPS, and uninstalled the database, cleared the directories, and then restarted the database (i.e., exactly what I’d done with my virtual image). (This is when I switched from MariaDB to MySQL, incidentally.)

… and what happened, you ask? Well, the same thing – lots of journal sequence errors. Here’s a sample:

151115 15:42:11  InnoDB: Error: page 1749 log sequence number 632633543
InnoDB: is in the future! Current system log sequence number 510316477.
InnoDB: Your database may be corrupt or you may have copied the InnoDB
InnoDB: tablespace but not the InnoDB log files. See
InnoDB: http://dev.mysql.com/doc/refman/5.5/en/forcing-innodb-recovery.html
InnoDB: for more information.

This was concerning. I was about to have to open up the MySQL files and alter them directly (which I’d been trying to avoid.) But I wanted to try one more thing, since I’d done the data dump on my virtual image…

So I shut down the database, and removed the data again. I restarted the database server, and created the database and database user.

Then I fed the SQL into the mysql client, and ran some simple queries to see record counts and some data. No errors.

Then I restarted WordPress … and lo and behold, everything seems to be okay.

The moral of the story is, of course, to make regular backups and watch your servers… I’m hardly a MySQL admin, and clearly I need to get better about all of this.

What would you do… if you really had money?

There’s a lot of whining lately about how the rich are getting richer, how it’s not fair, how dare they have stuff when we don’t… how dare they have money and keep it!

It got me thinking: what would I do if I had a lot of money? What effect would I really have?

I don’t know, honestly, never having been personally in the upper class, monetarily speaking. I’m clearly the best person I know, ethically and morally, but monetarily, not so much… and who am I kidding? I don’t think I’m the best person I know ethically or morally either. I know my own flaws.

But… if I somehow were to have a rich uncle of whom I knew nothing die, and leave me his billions, here’s what I think would happen:

  • My local schools, public and private, would find elective programs sponsored anonymously. Music programs, art programs, science programs, math programs, and english programs would find that they had basic supplies (and some freedom to specialize), and sports programs would have proper protective gear. I’d also sponsor homeschool cooperatives for the same purpose. (As a homeschooling parent, such resources are very sporadic.)
  • Programs that researched alternative energy would have grants, again anonymously.
  • My local food banks would have money to replenish their stocks, also granted anonymously.
  • My local shelters would have money to house and help people – not to keep them sheltered, but to enable them to no longer need shelter.
  • I’d have a nice house with a lot of acreage – not just because I want acreage (and boy, would I love to have land to wander) but I’d also use that land to provide caretaker jobs for those who struggle with other employment. I’d have strict requirements: no abuse allowed (alcohol, drugs, etc), no assaults (sexual or otherwise), but to someone who’s willing to commit to sane and safe living, help would be provided.
  • My family would have everything it needed – not the best of everything (although surely the best of some things, within reason). My money would hopefully serve as a launching pad, not a vehicle.
  • I would have some beautiful musical instruments: guitars, synthesizers, amps, drums, and rooms in which I could play. I’d have computers that provided me the freedom to create as I desired.

Now… what about those who do have money to do all of that? What do I think of them?

I don’t really worry about it. It’s their money, not mine. They should do as they want to do. I don’t think my ethics and values serve as condemnation to them; I know some people who have what I’d consider that kind of resources, but I don’t expect them to share with me or with others in any way other than what they do.

It’s up to them.

What would you do if you had an enormous sum of money available to you?

What are your bellwethers?

What things about someone would serve as simple signals as to whether you could empathize with them? What would your bellwethers be?

A “bellwether” is a leading or primary indicator of something.

It came up in conversation about the Lord of the Rings; I have friends for whom LoTR isn’t a pinnacle of fantasy.

What of it? To me, LoTR isn’t a bellwether – it’s just a series that I highly enjoyed (and continue to enjoy); the fact that I have friends who don’t like the series clearly says that liking LoTR is not a bellwether for me.

The only book that I can think of that would serve as a bellwether is To Kill a Mockingbird. I think if someone actively disliked TKaM, I’d question what it was about them that made me claim them as friends (I don’t think I’d say they weren’t friends, but I’d wonder what was wrong with them.)

That’s not to say that it would bother me if they didn’t think it was the greatest American book; it wouldn’t. It wouldn’t even bother me if they didn’t like the book – the bellwether would be a sort of dull rage against the book. Someone who actively disliked it… that would be someone with whom I’d question my ability to empathize. There’d be some resonance in their souls that I’d struggle to understand.

But… that’s it. Not the Bible, not Night, not Neuromancer, not Ender’s Game, not Alas, Babylon, not Lucifer’s Hammer; all good books, all books I have on my bookshelf in high regard… but if someone doesn’t like them, I shrug my shoulders and move on.

Each one of them has distinct value, in my opinion, but if they don’t resonate with a particular person, so what? It’s their preferences, compared to mine. No big deal.

I wonder, though: what would you say would be your bellwethers? What about someone would turn you off, for real? (If you can come up with a large list – discounting obvious things like “advocating rape” or whatever – well, maybe that’s a bellwether for me. A large list of reasons to be unable to empathize with someone says something fundamental about the holder of such a list.)