Archive for November, 2011

“Author” and “Committer” fields in git metadata…

Friday, November 18th, 2011

Discovered a nice little git trick today.  I haven’t seen this documented, so I’m not sure if it’s a feature per se, but if you set your user.name via git config like so:

[user]
    name = accountname
    email = email@company.com

and then commit with the --author="Full Name" flag set to another name, this will set git’s commit metadata such that “Author:” is “Full Name” and “Committer:” is “accountname”.

Useful when you want to see the Author in your git logs and the Committer in tools like Hudson or Jenkins.

MySQL Table Copying

Thursday, November 17th, 2011

It’s too bad the MySQL documentation reads like a drunken rant channeled in English through Leo Tolstoy reincarnated as a database geek, otherwise I might be more familiar with nice features such as

CREATE TABLE IF NOT EXISTS database_b.my_table SELECT * FROM database_a.my_table

which quickly copies my_table form database_a to database_b however given that it’s virtually impossible to read the MySQL documentation and because I cringe in horror whenever a MySQL doc page comes up in a Google search, especially since any search for anything MySQL related always results in a deluge of of links pointing into the inscrutable mess that passes for the MySQL reference site, I suppose I will forever be pining for a switch to PostgreSQL or, at the very least, not be be surprised when Oracle starts to charge exorbitant sums for consultants who are able to translate the MySQL documentation from neo-Leo Tolstoy techno-babble into succinct technical English.

Less Snarky Update

The above seems to behave differently on Windows than it does on Linux.  On Windows it will not copy data if the table already exists, the preferred behavior in my opininon.  On Linux it will copy (and potentially duplicate) data.

zend_mm_heap corrupted

Friday, November 11th, 2011

Has Apache suddenly started telling you that the “zend_mm_heap” is corrupted? Rather than mucking around with output_buffering or other php.ini values as recommend in a couple of places, first check that, if you have a custom session manager (typically memcached), it is started and you are able to connect.

For example, if your session handling is setup as follows:

[Session]
; Handler used to store/retrieve data.
; http://php.net/session.save-handler
;session.save_handler = files
session.save_handler = memcache
;session.save_path = "/tmp"
session.save_path = "tcp://localhost:11211?persistent=1&weight=1&timeout=1&retry_interval=15"

check to make sure that you can actually connect to localhost on port 11211:

$ telnet localhost 11211
Trying 127.0.0.1...
Connected to localhost.localdomain.
Escape character is '^]'.
stats
STAT pid 24041
STAT uptime 257289
STAT time 1321027200
STAT version 1.4.2
...
END

If you can’t connect, or the memcached server is not responding as above, then you’ve found the source of the “heap corruption”.

Doctrine Migrations and Jenkins

Wednesday, November 9th, 2011

If you’re trying to automate Symfony2/Doctrine2 migrations with Jenkins, you may run afoul of the interactive confirmation that the doctrine-migrations package throws out:

$ app/console doctrine:migrations:migrate

Application Migrations

WARNING! You are about to execute a database migration that could result in schema changes and data lost. Are you sure you wish to continue? (y/n)

This will break the Jenkins build. While there is probably a way to get Jenkins to reply to this with a “y”, it’s easier just to use the under documented --no-interaction switch. In a build.xml for example:

<target name="schema" description="Update database">
<exec executable="app/console" failonerror="true">
<arg line="doctrine:migrations:migrate --no-interaction" />
</exec>
</target>

Now if the migrations work, so does the build.

Delete email with a specific email address from the Postfix queue…

Tuesday, November 1st, 2011

HowtoForge still comes in handy. This is one of those times:

mailq | awk 'BEGIN { RS = "" } / falko@example\.com$/ { print $1 }' | tr -d '*!' | postsuper -d -

File under “what to do when postfix goes berserk”.