flak rss random

flak upgrade

The only thing more fun than talking about yourself is talking about the blog platform you use to talk about yourself. I rolled out some flak upgrades today and it almost worked. I did learn one critical lesson about sqlite which may be interesting, after that the post devolves into useless trivia.


The big change I wanted to make was storing revisions of posts, instead of just the current body text in a column. Every time I edited a long post to correct a minor typo, I was terrified some browser or network glitch would result in losing everything. I haven’t built a very good interface for retrieving past revisions, but at least now the table that contains all the data is essentially append only.

At the same time, I switched to using sqlite full text search for storing posts. Everything went well in testing, but fell apart in production. The culprit was that the live server was using an older 3.6 release, but I’d been using a fresh 3.7 release in development. One key feature I was relying on to tie the post text to its url is the last insert rowid function. Read the docs carefully. When using a virtual table (such as fts), the results of last_insert_rowid are only meaningful starting with version 3.7.7. I was getting back gibberish and so the body of a post would magically turn into the body of an entirely different post.

I figured I was safe because I’ve been using sqlite 3.6 for ages without trouble, including very similar code in mailtanium which uses fts. Admittedly, 3.6 is getting old, but it’s the version included with Ubuntu 10 LTS, and I’ve been using sqlite for so long it’s one of those components I don’t think about. Now I don’t know how mailtanium ever worked. (Also wouldn’t hurt if I tested the production rollout on something other than the production database. At least I had backups.) The really stupid thing was after noticing that the remotely upgraded database was all messed up, I upgraded a copy locally and uploaded it back to the server. That should have been a red alert triggering warning sign, but I wrote it off as fluke. There are no computer flukes.


I switched sqlite bindings from the functional but not really maintained luadbi to a home rolled FFI interface. This necessitated an upgrade to luajit, of course. To give it even more oomph, there are now four flak processes in the simplest load balancing config possible, all listening on the same socket.

Several features were dropped, because they were hard to test when I wanted while not triggering them accidentally. Such as Pushover notifications and the old RSS feed. There’s a new RSS feed now, native to flak, that doesn’t rely on the crazy web service hook experiment. The “middleware” layer of flak included some pretty cool (imo) rate limiting capabilities, but in the end they added a ton of requests to a redis server for each page load. Killing that eliminated one more unnecessary dependency.

On the new feature side, stealing an idea from Daring Fireball, I can mark a post as a minipost and it won’t show up in RSS or the recent posts list.


The style of flak is always subject to minor grinding. Word on the internet is the world isn’t black and white, so designs shouldn’t be either. Both flak’s background and foreground colors are skewed slightly towards blue. On the downside, I think this makes links harder to spot without underlines. I really don’t like underlines (and the site is hideous with every link underlined), but as a compromise links in post bodies are underlined again. (And not again.) I can’t go any lighter with the background (#eef) without resorting to six digit (#eeeeff) color codes. I like to stick with the shorter codes to avoid too many possibilities. Otherwise I’d be dicking about endlessly switching from #edeffe to #efedfd.

There’s a floating (or is it fixed?) table of contents bar at the bottom. I tried making it only semi opaque so your eyes don’t fixate on it, but that may have backfired. Sizing and positioning should be slightly better for high res mobile devices, but I don’t have nearly enough gadgets to know.


I still can’t fully upgrade flak without stopping and starting, leaving a few second gap where the site is down. This was the first incompatible database upgrade, which pushed the downtime window up to the thirty second mark. Then a mad scramble to figure out why editing didn’t work right, but at least reading the database was working.

Posted 09 Mar 2013 23:25 by tedu Updated: 21 Apr 2013 05:38
Tagged: flak programming web