New year, old bugs

Or: Old year, new bugs

Or: Bug of the week number

Or: It is the first week of 2009, but it is still 2008

We all know that date calculation is tricky. Don’t get me started on time zones! I’ve found a web-based time report application and an online movie rental site that fails to handle a wonderful corner case taking place right now, in the last days of year 2008.

Week numbers are used very often in Sweden, and of course they need calculation too. There is fortunately an ISO standard (mandatory Wikipedia link) that defines week 1 to be the the week with the year’s first Thursday in it. This is also the first week with four or more days in the new year.

This week is obviously week 1 by the above definition, as the first of January is on Thursday (tomorrow). There is also no denying that it we are still in the year 2008. (At least in Europe. Damn time zones!)

Let’s look at a time report application that might as well remain anonymous. By default it shows the current week, except for Monday-Wednesday this week:

(You guessed right: the Swedish word for “week” is “vecka”)

If I press the left arrow to move to the previous week, I get a time report page for week 52, year 2007. The right arrows takes me to the time report page for week 2, 2008. Oups!

An unnamed Swedish movie rental site shows the “New movies in December 2008” with “New this week”, but looking at the actual dates I’m pretty sure that people have been able to rent these movies for a whole year!

I should have started looking for more bugs like this already on Monday, because tomorrow I expect these bugs to be hidden and they will not show again for a few years! In about a year I might look for similar bugs appearing the days when it is the last week of 2009 but the year is 2010.

Happy new year!

Moved the first Ruby on Rails site from Apache to Lighttpd

Yesterday I managed to move the first Ruby on Rails site to its new home on the VPS. The move had been easier if I hadn’t decided to use Lighttpd this time around, but finally I got everything working. The site I moved is only the administration interface for the energy drink database used by taurin.se, but now I should be able to move that site too. The administration interface should probably also be upgraded from its ancient Ruby on Rails version, but I’m saving that for later. (Technical debt again?)

The Ruby on Rails parts of my Lighttpd configuration currently consists of a $HTTP[“host”] conditional like this:

$HTTP["host"] == "admin.taurin.se" {
    var.site = "admin.taurin.se"
    var.RAILS_ENV = "production"
    include "incl-rubyonrails.conf"
}

And the hopefully reusable include file incl-rubyonrails.conf looks like this:

server.document-root        = basedir + site + "/public"
server.indexfiles           = ( "dispatch.fcgi", "index.html" )
server.error-handler-404    = "/dispatch.fcgi"

fastcgi.server =  (".fcgi" => ( site =>
(
"socket" => "/tmp/" + site + ".fastcgi",
"bin-path" => basedir + site + "/public/dispatch.fcgi",
"bin-environment" => ( "RAILS_ENV" => RAILS_ENV )
)
))

The var.basedir variable is also set before including the file above.

Web and mail server connectivity issues

Not long after my FreeBSD file server at home was upgraded properly, my old web and mail server lost connection to the Internet.

The server was unable to connect to the Internet (and vice versa) from yesterday evening until midday today. The cause was presumably a routing problem in the network run by the crappy broadband provider Blixtvik. (Formerly Jacket, formerly IP-Bolaget, formerly Cenara…)

My new server is a virtual private server (VPS) from GleSYS but I have not prioritized to move all my stuff there before. Now it’s time! I’ve moved this blog there as a first step, only everything else remains… Unfortunately the server is running low on RAM (no swap on a VPS!) so I have ordered an upgrade to the “gold” package with 1024 megabytes RAM guaranteed (and twice as much available for bursts). I also get 8 CPU cores and other things that are nice but not strictly neccessary…

When the upgrade has been performed I will continue to move stuff. Right now it looks mostly like this at the command line:

bash: fork: Cannot allocate memory

Upgraded my FreeBSD file server

Upgrading a FreeBSD server should be less painful than putting a graphics card in a Windows server, unless there is a huge technical debt involved of course…

At home I’ve been upgrading my three year old FreeBSD file server. I bought 3 new 500 gigabyte hard disk drives for a new graid3 setup, but I forgot to buy a new SATA300 controller. Fortunately a friend found out where they still sell Promise SATA 300 TX4 PCI cards so I ordered one.

In the meantime I had some FreeBSD upgrading to do; the server was embarassingly still running FreeBSD 6.2! That old version does not have freebsd-update and it does not have portsnap.  I have not saved a complete log of my upgrade adventures and frustrations, but here are some highlights. Lets call it “paying technical debt”…

  • My ports tree was pretty broken so I moved /usr/local to /usr/local.old and /var/lib/pkg to /var/lib/pkg.old to get a fresh install. I also saved a pkg_info output for reference.
  • Upgraded from 6.2 to 6.3 (It seemed better than going to 7.0 from 6.2)
  • Upgraded from 6.3 to 7.0 (I was too much a coward to go for 7.1-RC1)
  • Not getting the 7.0 kernel to boot properly (atapci0: unable to map interruptpanic: Root mount failed, startup aborted) until I found that APIC was disabled in BIOS (wtf?) and enabled it.
  • Hoped to install all ports from binary packages (pkg_add -r) but then I didn’t get mod_sav_svn
  • Not getting pthread:ed ports to compile properly until i added a missing a symlink
  • Also forgot that I needed more SATA power cables, but fortunately I was able to buy the right cables in Karlskrona
  • Creating the graid3 was so quick and simple that I was afraid I forgot something: graid3 label storage2 ad8 ad10 ad14; newfs /dev/raid3/storage2

Thanks a lot to Jonas and Per for their helpful advice!

Solved problems installing a graphics card in a Windows 2003 Server

My computer troubles did not stop with the RAM failure on my laptop.

The next issue was a server upgrade at work. We needed to put a graphics card into a server. (Don’t ask why!) The HP ProLiant ML110 G5 server has a built-in Matrox G200e (with 8 megabytes of RAM) and I installed a  PNY Quadro NVS 290 with PCI-Express x1 interface. (The server only has PCI-Express up to x8, not x16 as 99% of all graphics cards require!)

It was not possible to disable the integrated graphics in BIOS so we only disabled it in the Windows Server 2003 Device Manager. So far so good! The weird thing was that Remote Desktop stopped working. It took me embarassingly long to find the relevant message in the Event Viewer: SystemRootSystem32RDPDD.dll failed to load. Once I found that message it didn’t take long to find and try the suggested solution and it worked at last!

Divide and Conquer Tip #2: Stack Overflow

It was months since I mentioned the Jeff Atwood and Joel Spolsky joint venture stackoverflow.com on this blog. The stackoverflow.com site has been up and running for a while now, and it is both a great resource for getting help, and a possible way to spend a lot of time online. The reward system is devilishly clever, with points awarded according to certain rules and badges handed out for achievements of various magnitude.

I would like a similar reward system on my site Folkmun, but it will take a while before I get even close…

Update What Was Stack Overflow Built With?

Mysterious crashes = RAM memory failure

I had some mysterious crashes on my Thinkpad T60p the other day. First I got Firefox hangs, second Firefox didn’t start, third I got segfaults when listing a directory on the hard disk, four I got kernel panic when running fsck…

Now I’m running Memtest86 and it does not look good:

That computer is soooo being sent to service!!!