PHP, multiple requests, and slow load times

Recently I did some major updating to a web application I wrote a few years ago. The web app was the usual LAMP stack and ran on 10-20 public kiosks.
The web app allowed an admin to run two kinds of reports on the data. The first report took a very long time to run, but the second report was much simpler and was usually quicker. After all the updates were done suddenly both reports took forever to run.

I had updated MySQL to the latest version and the database architecture had changed to support new features so I spent a lot of time re-examining how the db was set up and checked the indexes on the tables.

I then looked at the queries to see if any of them could be optimized. I added timers around queries that I thought might be slow, but everything seemed normal. Yet still the request times were abysmal.

I tried using xdebug to see if there were any processes that were being called that I was missing when reviewing the code, but everything was as expected there.

In the end I finally realized that the problem was with session. session_write_close(); was not being called in the reports scripts and so each request was locking the other out until it was done generating the report. This was a very simple thing that I overlooked.

When debugging its always best to start with the simple and move towards the complex. Checking that session was properly handled should have been one of the first things I checked. Long load times on concurrent request should’ve been a red flag, but so much had changed that I didn’t start at the beginning and instead dove into more complex areas that only muddied the issue. Its the sort of mistake that you tell yourself you’ll never do again, but somehow you end up repeating anyway.

SQL Server 2008 "Saving Changes is not permitted" error

Work just upgraded us developers to SQL Server Management Studio 2008. Developing in the test database I’m often quickly creating tables or modifying tables through Enterprise Manager. Once I was upgraded to 2008 I kept getting this error:

Saving changes is not permitted. The changes that you have made require the following tables to be dropped and re-created. You have either made changes to a table that can’t be re-created or enabled the option Prevent saving changes that require the table to be re-created.

I looked through the options but I could not find it. I can never find the option I’m looking for in MS products. A quick Google search showed me that it was right there all along. For anyone else that is blind and can’t navigate the menus you can turn this off here:

Tools->Options->Designers->Table and Database Designers->Prevent Saving changes that require table re-creation.

Coldfusion’s Missing Huffman code table entry error Redux

UPDATE

Updating Coldfusion with the newest patch did not work. We are still seeing the “Missing Huffman” error in production. This occurs a few times a day. I’m now attempting to use the work-around posted in the Adobe Thread on the issue.

Below is my version of the work around:


	
	
	
		
			newImageName =  createUUID() & ".jpg";
			// create a file object representing the path to the saved image
			outFile = createObject("java", "java.io.File").init( arguments.destination_path );

			// extract the underlying BufferedImage from your CF image object
			bi = ImageGetBufferedImage(myImage);

			ImageIO = createObject("java", "javax.imageio.ImageIO");
			// use ImageIO (instead of cfimage) to physically save the image to disk
			ImageIO.write( bi, "jpeg", outFile );
		
		
			
		
	
	

A Few Holes in Bruce Willis's Career

At lunch today my co-workers and I noticed a few holes in Bruce Willis’s career:

  1. The First Deadly Sin / Loaded Weapon 1 / Alpha Dog
  2. Die Hard 2 / Look Who’s Talking Too
  3. Four Rooms
  4. The Fifth Element
  5. The Sixth Sense
  6. Lucky Number Slevin
  7. The Whole Nine Yards
  8. The Whole Ten Yards
  9. 12 Monkeys/Ocean’s Twelve
  10. Sixteen Blocks

I don’t think anyone could say he did this is on purpose. I’m just wondering if he’ll be able to fill in the gaps before he dies.

Coldfusion's Missing Huffman code table entry error

UPDATE

While working on a content management system with functionality to allow users to upload images there was an error that would occur seemingly at random. When a user uploaded a jpg nine times out of ten it would work fine, but every so often there would be an error “Missing Huffman code table entry”.

After some Googling I discovered on this blog that this is a bug in Coldfusion 8. Adobe has patched it and you can fix the issue by making sure you’ve installed the latest hot patch to Coldfusion 8. You can download the patch here.