Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Doctor Q

Administrator
Original poster
Staff member
Sep 19, 2002
39,782
7,514
Los Angeles
No, our skulls are not bigger to hold larger-than-average brains. We have lumps on our heads from banging them on the wall when things like this happen:

I use a program every morning to display a list of recent changes to a customer database, as a double-check that things look fine. This way, if there is a problem in the database system, say from an errant automated process, I will notice that a large number of records have been added, removed, or changed, and I can check that it was intentional.

I wrote the program myself and it's worked fine for over a year. Today I turned over the task of running the program to a coworker who has inherited the task. But it didn't work when he tried it! I made sure it had nothing to do with his login name (the program doesn't care who runs it and it uses the database under the same credentials no matter who runs it). So it was clearly impossible that it always worked for me and failed for him, right?

After banging on my head on the wall for a while (the usual technique for programmers to solve impossible problems), I discovered the problem wasn't getting solved, so I went to Plan B: debugging the program. I'm sure you'd like to know what the answer turned out to be.

Answer: The program used a temporary filename based on the operating system process ID, and a form in which the filename was used had a field with a limited character size. If the script was run early in the day when process IDs were lower on a system that was booted each day, the process ID was four digits long and the filename field fit on the form. If the script was run later in the day when process IDs were higher, the process ID was five digits long and the filename field was truncated!

I ran the program first thing each day. My coworker tried it in the afternoon. Sure enough, when I shortened the temporary filename, it started working for him too. At any time of day!

The problem is solved, but I seem to have a lump on my head. Thanks for listening.
 

lopresmb

macrumors 6502
Apr 29, 2005
289
0
well congrats, I suppose all's well that ends well (except the head thing). Just keep reminding yourself - you are smarter than the machine, he works for you :D. That and just make sure the head blows don't land on the actual computer, which has the unfortunate likelyhood of rendering the hardware you are working with inneffective ;)
 

Mitthrawnuruodo

Moderator emeritus
Mar 10, 2004
14,422
1,063
Bergen, Norway
He-he... the solution is always trivial once identified... :)

At least it wasn't one of those bugs that spawn a whole new gang of bugs once you correct the original... or so it seems at least... ;)

And I normally don't get the lumps on my (fore)head until the bug is found, and then only because I bang my head against the table for being so stupid not to find it earlier... :D
 

Mr. Anderson

Moderator emeritus
Nov 1, 2001
22,568
6
VA
why did you limit yourself on the temporary file name? I'm thinking its one of those things that seemed ok at the time - but in hindsight, making a temporary file that you create and delete from the program - you could have just made it the same every time - like tempfile.txt or whatever :D

How long did it take you to figure out the problem? That one seems like a pain.

D
 

Doctor Q

Administrator
Original poster
Staff member
Sep 19, 2002
39,782
7,514
Los Angeles
I don't use the same temporary filename each time because two people, in theory, could use the program at the same time and each would need a distinct temporary file. Using the process ID in the filename is a standard trick.

It didn't take me long to track down the problem, as it turns out, because I had built in some debugging options to show you the progress as it executed. When it claimed to have created a file but then was unable to find it, I looked in the target folder and found a filename that had a digit missing at the end. Aha!
 

dcv

macrumors G3
May 24, 2005
8,021
1
i was curious about this thread...

here's what it looks like from the index page!
 

VanMac

macrumors 6502a
May 26, 2005
914
0
Rampaging Tokyo
I fell off a cliff when I was younger, landed on my head, and got a pretty knarly bump and gash still today. It explains a lot. :confused:
 

Lacero

macrumors 604
Jan 20, 2005
6,637
3
dietcokevanilla said:
here's what it looks like from the index page!
There's an opportunity to come up with a great dirty joke in there somewhere. :p
 

dcv

macrumors G3
May 24, 2005
8,021
1
Lacero said:
There's an opportunity to come up with a great dirty joke in there somewhere. :p

My comment was intentionally left open to interpretation... but i'm sure you can guess what i was thinking...




pay-cheques *of course*

believe that, you'll believe anything...i'm a cheeky girl really... hehe
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.