Strange errors and load issues when php 5.2 -> php 5.3.x debian

Hi something very bizarre happened. I had originally downgraded my Debian Squeeze to Php 5.2.x using the lenny repos due to some software which could not handle php 5.3.x. This had been the case for about a year and elgg was working fine. Tonight I upgraded back to php 5.3.x with the current stable on Debian Squeeze.

All sorts of weirdness hit one of my high traffic Elgg installs! At first granted I had issues to fix with the ioncube loader and the removing of zend optimizer but even after that and restartign all relevant services multiple times I noticed my Elgg install would work for a while and then the apache error log would show all sorts of "too many connections" errors connecting to mysql. Then eventually it would just show errors as if it could not connect at all to the database as if I had bad info in settings.php.

After restarting many times, upgrading from the old 1.8.11 to 1.8.13 (just to see if that helped), checking the databases, and finally being seconds away from wiping out the install and restoring from a week old backup it suddenly seems to be working again. Just like that.

I also saw some deprecated messages when doing 'php -v' regarding magic quotes and register_long* and I took care of these but I don't see how they would cause this.

Does anyone have any ideas to possibly explain this? I'm worried this might come back again and would prefer to be ready. I was at a loss when this was happening and felt pretty helpless so any leads would be great just so I can be better prepared and handle it next time. As it is now like I said I have no idea what solved it.