Today’s interesting discovery

My navaid.com web site uses a tiny bit of Ajax in order to refresh a portion of a page showing how many waypoints have been generated so far, when you’re generating a database. A couple of people reported that it wasn’t working right with IE 7. I discovered that IE 7 has attempted to implement the XMLHttpRequest the same as standards compliant browsers (Firefox, Opera, Safari), and that was my first thought. I upgrade IE on my Windows box to IE 7 and tested it, and sure enough it didn’t work right, and turning off the option that says “Enable native XMLHttpRequest support” did make it work right.

But I can’t expect every user of my site to turn off this option, so I went searching for a better answer. And I discovered something else – IE is fanatical about caching pages, no matter what the web server tells you about the age of the page. So I added the following line to my page’s javascript:

this.req.setRequestHeader(‘If-Modified-Since’,
‘Sat, 1 Jan 2000 00:00:00 GMT’);

and that seems to have fixed it. Unfortunately, because IE is so fanatical about caching stuff, I’m betting that a bunch of my users won’t see the changed net.js until they’ve already decided it doesn’t work.

Finally, something worked right!

The last thing I’m going to be moving from my linode VPS to my colo box is my Navaid.com waypoint generators. I’ve started doing some work on that – originally I was going to export the MySQL database from the linode, and massage them and import them into PostgreSQL on the colo box. But when I first started doing that, I found no end of trouble – the version of MySQL in Debian Sarge doesn’t have the “compatibility” mode in the dump command, plus I discovered that when I’d originally moved from PostgreSQL to MySQL I’d converted all the boolean fields to tinyint(1) or something, and I’d like to change that. Plus there were fields that were set to “not null default 0” which should really have allowed nulls and the like. Basic clean-up stuff, but time consuming. So I’d decided to bring the database over as MySQL, and maybe bring up the site in MySQL and write a conversion script later on so I could convert to PostgreSQL later.

Thursday evening while experimenting with some of the scripts navaid scripts on the colo site, I discovered some bad values. Investigation proved that the FAA had changed the data format for the “APT” airport record in the last load, and I hadn’t adapted my load script.

So Friday evening I went back to the “real” navaid site and fixed the load script, and ran the two scripts to reload the data. I started the run about 8pm. But it was going *really* slow. So while I was waiting, I copied the changes over to the same scripts on the colo site and ran them there. The two scripts took less than a hour to run, which pleased me immensely, and I was able to verify on that site that the damage was fixed. But the scripts on the real site were still running. I waited and finally went to bed. When I got up this morning, the first script was still running. As a matter of fact, it finally finished and went on to the second script at about 2pm. It’s slowly grinding through the second one.

But I didn’t want my “real” site to be down for this length of time. So I hit on an idea – I enabled remote connections to the MySQL database on my colo box, and made a test version of the generation script on the real site with a slightly different “DBI->connect” line as the only change. And it worked, and it worked amazingly quickly. So I changed the whole site over, and restarted Apache, and so now the web services are running on the “real” site, but the database they are hitting is on the colo box. This will make the ultimate migration easier, and it means that navaid.com’s users are already getting a bit of a speed advantage from this move.

The only hitch, and it’s a small one, is there is a script that runs once a night to expire old saved sessions. It uses subqueries, which the MySQL on my colo box doesn’t support. I’m going to have to re-write that as a script that uses a left inner join to find the ones to delete, and then deletes them one at a time. The reason why this worked on my VPS box and not on my colo box is that on the VPS, I’m connecting to a MySQL server provided by the ISP, not my own. So while Debian Sarge installs MySQL 4.0.24, the server I’m connecting to is newer than that.

I thought I was the mightly debugging king…

…but I just handed my debugging crown to him.

Kris and I have been banging our heads on our desks because of problems we’re having with our JTreeTables. A JTreeTable is a class that we found on a Sun Java forum that combines the attributes of the JTable with a JTree – basically giving you JTree behaviour with columnar (table) data. It’s really handy. But frequently, and often in cases I could easily reproduce, the damn thing wasn’t updating correctly. Kris and I both made sure that our updates were properly protected by synchronization locks, and the events were being fired in the event loop, lessons we’ve both learned by hard experience. But it was still acting strangely. Kris spent a lot of time reading forum posts, running the debugger down deep in Java library code, and basically working this problem from all angles for days upon days.

Yesterday he found the problem. And the problem was in my code. When you fire an event, you need to give it an array of Objects that starts at the root node of the tree, and follows down through the tree to the node that actually changed. But of course, when you actually change a node, you’re already at the node that changed, and it’s pretty easy to trace up from node.parent() to node.parent() until you reach the top, so that’s what I do. And then I attempt to reverse the order of what I’ve got to make the required array. But it appears that I fundamentally misunderstood the Stack class, because pushing objects on the Stack and then doing a “toArray” on it doesn’t reverse the order, as I’d thought. So the view was getting a totally messed up event, and that was messing everything else up.

Kris changed my Stack.push into ArrayList.add(0, node), and everything works now. And I never thought about doing it that way because I thought List.add(0, Object) would replace the object at position 0, not push them all up.

And Kris’s small change (after big effort) closes three bug reports assigned to me, and a bunch that were assigned to him.

In my defence, I’d actually come up with the Stack thing while Vicki was driving us to Pittsburgh. So perhaps it wasn’t my best work.