ColdFusion 8 and MySQL 5.1 via JDBC: Help needed! [Solved]
UPDATE: We have now found the cause of the issue. Please scroll to the end of the article for explanation and workaround.
In one of our latest projects we need to access a MySQL 5.1 server (5.1.45) from ColdFusion 8 (8,0,1,195765). Creating the datasource was no problem, the datasource does verify okay - but there obviously is some bug or incompatibility in ColdFusion that causes the connection to be anything but reliable.
PostgreSQL DBA Snippet: Largest Tables in a Database
For my own reference - this little query will list all the tables in the current database with their respective physical size, including indexes and TOAST:
SELECT table_schema , table_name , pg_size_pretty(pg_total_relation_size(table_schema || '.' || table_name)) , pg_total_relation_size(table_schema || '.' || table_name) FROM information_schema.TABLES WHERE table_type = 'BASE TABLE' ORDER BY pg_total_relation_size DESC;
Oh shut up, cfmemcached!
Over the last few months, our use of memcached has not so much grown but more like exploded. The cfmemcached project on RIAForge has been a great starter for us. The author is using spymemcached, a very useful memcached client implementation for Java.
As much as I immediately fell in love with cfmemcached as a developer, the admin in me began to be seriously annoyed by the underlying spymemcached's chattyness that was filling up my ColdFusion server log with useless babble about each and every connection it had with the memcached servers:
2010-04-01 14:28:43.569 INFO net.spy.memcached.MemcachedConnection: Added {QA sa=/192.168.222.80:11211, #Rops=0, #Wops=0, #iq=0, topRop=null, topWop=null, t
oWrite=0, interested=0} to connect queue
2010-04-01 14:28:43.570 INFO net.spy.memcached.MemcachedConnection: Added {QA sa=/192.168.222.81:11211, #Rops=0, #Wops=0, #iq=0, topRop=null, topWop=null, t
oWrite=0, interested=0} to connect queue
2010-04-01 14:28:43.576 INFO net.spy.memcached.MemcachedConnection: Connection state changed for sun.nio.ch.SelectionKeyImpl@5081e9d3
2010-04-01 14:28:43.577 INFO net.spy.memcached.MemcachedConnection: Connection state changed for sun.nio.ch.SelectionKeyImpl@11e44f0
2010-04-01 14:28:59.476 INFO net.spy.memcached.MemcachedConnection: Added {QA sa=/192.168.222.80:11211, #Rops=0, #Wops=0, #iq=0, topRop=null, topWop=null, t
oWrite=0, interested=0} to connect queue
2010-04-01 17:02:37.723 INFO net.spy.memcached.transcoders.SerializingTranscoder: Compressed java.lang.String from 20798 to 4387
2010-04-01 17:02:37.731 INFO net.spy.memcached.transcoders.SerializingTranscoder: Compressed java.lang.String from 55548 to 9819
2010-04-01 17:02:41.866 INFO net.spy.memcached.transcoders.SerializingTranscoder: Compressed java.lang.String from 391919 to 45429
etc.
After a bit of research I discovered that this beast can be configured to use Log4J and I could thus shut it up quite nicely. All that is necessary are a few additions to our jvm.config and a Log4J-properties-file.
I've got a CF multi-instance install in /opt/jrun4/. I modified the jvm.config in the bin subdirectory of my installation and added the following to the java.args-line:
-Dnet.spy.log.LoggerImpl=net.spy.memcached.compat.log.Log4JLogger -Dlog4j.configuration=file:/opt/jrun4/bin/log4j.properties
(please note that there are no linebreaks in here!)
Then I created the log4j.properties-file in /opt/jrun4/bin/. This contains just two lines so far:
log4j.rootCategory=info log4j.category.net.spy.memcached=warn
After a restart of the instance, no more chatter. Enjoy the silence!
Death to isDefined()
Ever come across a couple of lengthy stack traces in your ColdFusion logfile that start with something like "Error in blah - java.net.SocketException: Broken pipe"? Here's what that's about:
While isDefined() may be a convenient way to check the existence of a certain variable, you just should avoid it at all cost and use structKeyExists([SCOPE],"[variableName]") instead.
Not only will structKeyExists() be much faster than isDefined(), as you've told ColdFusion where to look for your variable, so it doesn't have to check through all available scopes. You'll also avoid a lot of useless chatter clogging up your server's log files.
Say you're looking for a variable which at this point is in fact not defined in any of the available scopes and you're using evil isDefined() to do the job. ColdFusion will scan all the available scopes and eventually it would check the CGI-scope, too. And here's our problem: If the original connection from browser to webserver has already been closed in the meantime, which may happen for various reasons, the JRun connector (i.e. the bit that does the communication between webserver and the Coldfusion Application Server) will obviously fail to read the HTTP connection header and tell that tale in the log file in quite excessive detail, full stack trace and everything, although you really couldn't care less about it.
So in essence: Just pretend you never heard of isDefined(). structKeyExists() ist so much nicer and will give you a warm fuzzy feeling all over every time you use it.
CF Instance Hangs, “too many open files” in Log
This is really quite trivial, but may be of some interest to people who don't know too much about Linux OS tweaking. Today our dev-server instance was hanging - again. Only this time I took the liberty to make our developers wait a little longer before I restarted it, so I could actually diagnose the issue and resolve it for good. As only one of our two instances was hanging, I took a peek into its logfiles first - but couldn't find anything out of the ordinary. And the Enterprise Manager reported the instance to be running, too.
ColdFusion 8 and Symlinks – Hell Awaits? (solved)
UPDATE: The issue seems to be fixed with ColdFusion Hotfix hf801-71648 (see technote kb403629). The fix is included in the Cumulative Hot Fix 2 for ColdFusion 8.0.1 (see technote kb403781). My bad - I thought I had deployed the hotfix when all I had in fact done was upload the zip-file instead of the jar. Epic fail. Anyway, the technote is a bit misleading as well - it's talking about Application.cfm path resolution when the same issue applies to cfinclude, too.
UPDATE 2: This hit us today again. I usually download the ZIP-Archives of the updates and just unzip then in place before restarting coldfusion. For some reason two of our five CF-servers decided to include chf8010002.zip into their classpath instead of the chf8010002.jar that was sitting right next to it. I cannot imagine how CF decides that a ZIP-file would be a valuable addition to its classpath, but only after I simply removed the original ZIPs and restarted the server, the JAR was correctly included and the annoying symlink resolving went away.
I recently stumbled over an issue when using symbolic links on a couple of ColdFusion applications. I intended to use symlinks to keep duplicate code between different applications to a minimum. I'm running Apache 2.2 with ColdFusion 8.0.1 on 64-bit Debian Etch. Each of our web-applications needs a "connector" while retaining an include with some site-specific config.
Using content compression with ColdFusion and SSI
This is actually an old story, just wanted to blog this so it might eventually help somebody else...
You probably know that most web-pages you'll find nowadays don't come as plain textfiles through this series of tubes, but the content is actually gzip-compressed server-side and unpacked by your browser, as long as the latter signals the server that it actually digests compressed content, which it usually does by sending the appropriate header.
Anyway, compressing static content is quite simple, you'd use something like mod_deflate with Apache2 or mod_gzip with Apache 1 and I am sure there are similar options for other webservers.
Compression of ColdFusion-generated pages is a little trickier though - mod_deflate doesn't seem to help you here.