Thursday, August 11, 2011

PostgreSQL server doesn't start in OS X

My PostgreSQL server is an EnterpriseDB product. It was installed using their installer. Suddenly one day, while watching a YouTube video, my computer hung. I had to restart OS X Snow Leopard (10.6), and after the restart, I couldn't connect to my PostgreSQL server: it wouldn't start. Even restarting Snow Leopard didn't help.


So I checked Snow Leopard's launchctl, which was responsible for starting processes at startup. 



sudo launchctl list |grep post
549 1 com.edb.launchd.postgresql-9.0




Not good. The second number tells me that postmaster has exited with a value of 1. Which most Unix users will know is an exit with error.



So OS X is launching the postmaster, but postmaster keeps exiting with an error. So what's the error? I'll try to launch postmaster in the exact same way that OS X is trying to launch, but I'll do it on the command line, so I can see the error myself.



First, I got to find the command that Launchctl uses. I thus open "/Library/LaunchDaemons/com.edb.launchd.postgresql-9.0.plist":



<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
        "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Disabled</key>
    <false/>
        <key>Label</key>
        <string>com.edb.launchd.postgresql-9.0</string>
        <key>ProgramArguments</key>
        <array>
                <string>/Library/PostgresPlus/9.0SS/bin/postmaster</string>
                <string>-D/Library/PostgresPlus/9.0SS/data</string>
        </array>
        <key>RunAtLoad</key>
        <true/>
    <key>UserName</key>
    <string>postgres</string>
    <key>KeepAlive</key>
    <dict>
         <key>SuccessfulExit</key>
         <false/>
    </dict>
</dict>
</plist>


This tells me the command to run is "sudo /Library/PostgresPlus/9.0SS/bin/postmaster -D/Library/PostgresPlus/9.0SS/data". So I run that:



"root" execution of the PostgreSQL server is not permitted.
The server must be started under an unprivileged user ID to prevent
possible system security compromise.  See the documentation for
more information on how to properly start the server.



Ok. Can't execute that command as root. I know that PostgreSQL server is started under the user "postgres". So I try that:

sudo -u postgres /Library/PostgresPlus/9.0SS/bin/postmaster -D/Library/PostgresPlus/9.0SS/data

GMT FATAL:  lock file "postmaster.pid" already exists
GMT HINT:  Is another postmaster (PID 62) running in data directory "/Library/PostgresPlus/9.0SS/data"?


Ahhhh… Apparently another process has opened the pid lock file. Next step is to kill that offending process and try again. I can do it on the command line, but where possible, I try to do it using OS X's GUI :) Steve wants it done his way… So I open Activity Monitor, find PID = 62, and "Quit Process".

Everything is now fixed.


Tuesday, August 2, 2011

"An internal build error has occurred. Right-click for more information"

This has to be the most irritating compiler error description ever in the Flex compiler in Flash Builder 4 for Eclipse.


I opened up the "error log" view in Eclipse, and saw that Macromedia (now Adobe)'s parser was throwing an exception "java.lang.ClassCastException: macromedia.asc.parser.MetaDataEvaluator$KeyValuePair cannot be cast to macromedia.asc.parser.MetaDataEvaluator$KeylessValue"


No help there.


I then found the issue. In my case, it was a bad coding that was actually valid syntax:



private var fileLoadIsComplete = Boolean = false;



This should be 



private var fileLoadIsComplete : Boolean = false;



My only advice is to start commenting out recent code until you find the offending line that caused the "internal build error".