Bucardo, 9.1, and you!
A little bit of bad news for Bucardo fans, Greg Sabino Mullane won’t be making Postgres Open due to scheduling conflicts. But not to worry, I’ll be giving the “Postgres masters, other slaves” talk in the meantime in his place.
In looking over the slides, one thing that catches my eye is how quickly Bucardo is adopting PostgreSQL 9.1 features. Specifically, Unlogged Tables will be very useful in boosting performance where Bucardo stages information about changed rows for multi-database updates. I also wonder if the enhanced Serializable Snapshot Isolation would be helpful in some situations. Innovation encouraging more innovation, gotta love open source!
If I hadn’t said it before, thanks to everyone that made Postgres 9.1 possible. Some of the other enhancements are just as exciting. For instance, I’m eager to see some creative uses for Writable CTE’s. And it’ll be very interesting to see what additional Foreign Data Wrappers pop up over time.
Now, back to packing…
conference postgres bucardo
OpenSSH known_hosts oddity
A new version of the excellent OpenSSH was recently released, version 5.9. As you’d expect from such widely-used mature software, there are lots of minor improvements to enjoy rather than anything too major.
But what I want to write about today is a little surprise in how ssh handles multiple cached host keys in its known_hosts files.
I had wrongly thought that ssh stopped scanning known_hosts when it hit the first hostname or IP address match, such as happens with lookups in /etc/hosts. But that isn’t how it works. The sshd manual reads:
It is permissible (but not recommended) to have several lines or different host keys for the same names. This will inevitably happen when short forms of host names from different domains are put in the file. It is possible that the files contain conflicting information; authentication is accepted if valid information can be found from either file.
The “files” it refers to are the global /etc/ssh/known_hosts and the per-user ~/.ssh/known_hosts.
The surprise was that if there are multiple host key entries in ~/.ssh/known_hosts, say, for 10.0.0.1. If the first one has a non-matching host key, the ssh client tries the second one, and so on until it …
hosting security
CSS Fixed, Static Position Toggle
In a recent Rails project, I had to implement a simple but nifty CSS trick. A request came in to give a DOM element fixed positioning, meaning as the user navigates throughout the page, the DOM element stays in one place while the rest of the page updates. This is pretty common behavior for menu bars that show up along one of the borders of a window while a user navigates throughout the site. However, this situation was a bit trickier because the menu bar that needed fixed positioning was already a few hundred pixels down the page below header and navigation content:
I came up with a nifty way of using jQuery to toggle the menu bar CSS between fixed and static positioning. The code uses jQuery’s scroll event handler to adjust the CSS position setting of the menu bar as users scroll through the page. If the window scroll position is below it’s original top offset, the menu has fixed positioning at the top of the window. If the window scroll position is above it’s original top offset, the menu has static positioning. Here’s what the code looks like:
var head_offset = jQuery('#fixed_header').offset();
jQuery(window).scroll(function() {
if(jQuery(window).scrollTop() < …css javascript jquery
Postgres Open: One week to go!
Wow, time flies, Postgres Open is almost upon us!
I’ll be there giving a talk Thursday morning on monitoring tools and techniques, and possibly helping with the Bucardo 5 replication session Friday afternoon. Sadly I’ll need need to catch a flight shortly after that, so there won’t be much time to explore Chicago around everything going on. But at least it’ll be nice to get out to a conference again!
conference postgres
SQL errors in Interchange
Interchange has a little feature whereby errors in a [query] tag are reported back to the session just like form validation errors. That is, given the intentional syntax error here:
[query ... sql="select 1 from foo where 1="]Interchange will paste the error from your database in
$Session->{errors}{'table foo'}That’s great, but it comes with a price: now you have a potential for a page with SQL in it, which site security services like McAfee will flag as “SQL injection failures”. Sometimes you just don’t want your SQL failures plastered all over for the world to see.
Simple solution:
DatabaseDefault LOG_SESSION_ERROR 0in your Interchange configuration file, possibly constrained so it only affects production (because you’d love to see your SQL errors when you are testing, right?).
interchange sql
Ruby on Rails Performance Overview
Over the last few months, I’ve been involved in a Ruby on Rails (version 2.3) project that had a strong need to implement performance improvements using various methods. Here, I’ll summarize some the methods and tools used for performance optimization on this application.
Fragment Caching
Before I started on the project, there was already a significant amount of fragment caching in use throughout the site. In it’s most basic form, fragment caching wraps a cache method around existing view code:
<%= cache "product-meta-#{product.id}" %>
#insert view code
<% end %>And Rails Sweepers are used to clear the cached fragments, which looks something like the code shown below. In our application, the Sweeper attaches cache clearing methods to object callbacks, such as after_save, after_create, before_update.
class ProductSweeper < ActionController::Caching::Sweeper
observe Product
def after_save(record)
expire_fragment "product-meta-#{product.id}"
end
endFragment caching is a good way to reuse small modular view components throughout the site. In this application, fragment caches tended to contain object meta data that was shown on various index …
performance ruby rails
Bucardo PostgreSQL replication to other tables with customname
Image by Flickr user Soggydan
(Don’t miss the Bucardo5 talk at Postgres Open in Chicago)
Work on the next major version of Bucardo is wrapping up (version 5 is now in beta), and two new features have been added to this major version. The first, called customname, allows you to replicate to a table with a different name. This has been a feature people have been asking for a long time, and even allows you to replicate between differently named Postgres schemas. The second option, called customcols, allows you replicate to different columns on the target: not only a subset, but different column names (and types), as well as other neat tricks.
The “customname” options allows changing of the table name for one or more targets. Bucardo replicates tables from the source databases to the target databases, and all tables must have the same name and schema everywhere. With the customname feature, you can change the target table names, either globally, per database, or per sync.
We’ll go through a full example here, using a stock 64-bit RedHat 6.1 EC2 box (ami-5e837b37). I find EC2 a great testing platform—not only can you try different operating systems and architectures, but …
bucardo cloud database postgres
Building Xpdf on Ubuntu
It may happen that you need to use Xpdf, even though it no longer ships with Ubuntu and is considered … outdated? buggy? insecure? In any case, it still renders some PDFs that Poppler-based viewers such as Evince don’t, or allows some troublesome PDFs to print as fonts and line art instead of a rasterized mess.
Here’s how I built and installed xpdf 3.02 on Ubuntu 11.04 (Natty Narwhal) x86_64:
sudo apt-get install libfreetype6-dev libmotif-dev
wget ftp://ftp.foolabs.com/pub/xpdf/xpdf-3.02.tar.gz # now 3.03 is current
tar xzpf xpdf-3.02.tar.gz
cd xpdf-3.02
./configure --with-freetype2-library=/usr/lib/x86_64-linux-gnu \
--with-freetype2-includes=/usr/include/freetype2 \
--with-Xm-library=/usr/lib \
--with-Xm-includes=/usr/include/Xm
make
# see lots of warnings!
sudo make installThat’s it. Not as nice as the old native Debian/Ubuntu packages, but gets the job done.
graphics open-source tips ubuntu pdf
