FreeBSD and pg_upgrade

Thank you kreynolds, your post makes my current job look dead easy. I want to upgrade PostgreSQL from 9.3.12 to 9.5.4, and after checking through all of the release notes between the two versions, I have narrowed the relevant ones down to the two biggest releases: 9.4 and 9.5 (thanks in part to our devs not using the darkest corners of PostgreSQL features… yet).

A side note: PostgreSQL is a shining example of how to do release notes. All in one place, linked properly between versions, available back as far as the eye can see, to pre-1.0 in the 1990s!

Another win for documentation: the FreeBSD handbook. Curated by members of the project, a simple URL, and quality information.

I could use pg_dumpall > backup.sql, upgrade the package, then psql -f backup.sql postgres, or do it in place faster with pg_upgrade. FreeBSD doesn’t simply allow both old and new packages to be installed together, so enter jails.

# jailroot=/usr/tmp/pg_upgrade
# bsdinstall jail $jailroot
# pkg -r $jailroot install postgresql93-server

In the dialog boxes, choose a nearby mirror and no extra components. Wait for the installation to complete.

# su pgsql -c 'pg_dumpall -c | bzip2' > /usr/tmp/pgdump.sql.bz2
# service puppet stop
# service postgresql onestop
# pkg delete postgresql93-client postgresql93-contrib postgresql93-server
# mv /usr/local/pgsql/data{,.93}
# pkg install postgresql95-client postgresql95-contrib postgresql95-server
# service postgresql oneinitdb
# pg_controldata -D /usr/local/pgsql/data.93

“Latest checkpoint location” needs to be the same on master and replication slaves. pg_upgrade(1) has good information on the 16 step process.

# su -l pgsql -c "pg_upgrade -b $jailroot/usr/local/bin -B /usr/local/bin -d /usr/local/pgsql/data.93 -D /usr/local/pgsql/data -j 16 -k --check"
Checking for reg* system OID user data types       fatal
Your installation contains one of the reg* data types in user tables.
These data types reference system OIDs that are not preserved by
pg_upgrade, so this cluster cannot currently be upgraded. You can
remove the problem tables and restart the upgrade. A list of the problem
columns is in the file:
    tables_using_reg.txt
[root@flora ~]# wc -l ~pgsql/tables_using_reg.txt 
 38 /usr/local/pgsql/tables_using_reg.txt

Bother. I can’t use pg_upgrade. Oh well, I’ll talk to the devs for next time, and get on with dump and restore.

Tribute to Nice

A professional cyclist and a pretty decent orator, I’ll let Tom Dumoulin’s words speak for themselves.

It’s a beautiful stage win on a very very sad day
We all woke up with the news or maybe you saw it last night
but I woke up with it
and then cycling is not important any more huh, for a few a moments
and maybe it still isn’t
but the organisation decided to race and I think it was a good decision
We cannot let terrorists decide our lives I think
I’m happy and very sad at the same time

PostgreSQL backup and replication systems

There are too many PostgreSQL backup and replication systems for me to keep track in my head, so here’s a list, with a few details relevant to me. The high availability matrix helped, and I found BDR performance discussion helpful, even if I didn’t pay close attention to which-one-is-fastest.

Name Installation Summary
BDR  from source Custom psql binary, asynchronous multi-master replication, high performance
Bucardo  ports tree Asynchronous multi-master or master-slave replication
OmniPITR  github Scripts to manage and monitor WAL replication, hot backups from master or slave servers
pg-rman  ports tree
pgbarman  ports tree Hot physical backup, point-in-time recovery management
pgbarman plugin: pgespresso  ports tree Enables backup from standby server
pglogical  ports tree Logical (cf physical) master-slave replication, postgresql >= 9.4, high performance, flexible, no hot standby state
pgpool-II  ports tree Synchronous multi-master replication, requires conflict resolution
postgresql hot standby  built in
repmgr  ports tree Manage and monitor replication and failover to standby server
Slony-I  ports tree
Skytools, Londiste  ports tree Asynchronous master-slave replication

I reckon pgbarman plus pgespresso plus repmgr (all from 2ndQuadrant) will do what I want. OmniPITR probably would too, with what looks like easier setup against potentially fewer restore options.

How to test a FreeBSD port

I am testing a new port written by Palle Girgensohn (https://github.com/girgen). He sent me the link https://github.com/girgen/freebsd-ports/tree/master/sysutils/filebeat to test.

I’ve never done this before, so I started thinking of how I might do so.

https://github.com/girgen/freebsd-ports being a fork of https://github.com/freebsd/freebsd-ports which in turn appears to be the mainline FreeBSD ports tree, I thought it would be possible to just get sysutils/filebeat into my own mainline ports tree (which I maintain with portsnap). So, combining my svn knowledge and git ignorance, I tried this:

root@travis:/usr/ports/sysutils # git clone
https://github.com/girgen/freebsd-ports/tree/master/sysutils/filebeat filebeat
Cloning into 'filebeat'...
fatal: repository 'https://github.com/girgen/freebsd-ports/tree/master/sysutils/filebeat/' not found

A bit of searching tells me I can’t simply do a subtree clone or checkout. I decided to do this:

root@travis:~ # mv /usr/ports /usr/ports.bak
root@travis:~ # git clone https://github.com/girgen/freebsd-ports /usr/ports

This worked, but (unsurprisingly) took a long time. I could then test the new port with the usual commands:

root@travis:~ # make -C /usr/ports/sysutils/filebeat install

So, I’ve achieved my short term goal, but it has left me wondering – how do other people do this? People who regularly test new ports or similar activity on anything other than the mainline ports tree surely have more streamlined practices. Somewhat complicated git commands to do a ‘sparse checkout’? Is it normal practice that Palle Girgensohn provided me a fork of the entire ports tree? I could ask him to do it differently. Hmm, I wonder if I could fork a subset of his fork, and then clone my entire ‘subfork’.

Thoughts welcome.

Dear Prime Minister Turnbull, please fix foreign aid

I am writing in support of Australian foreign aid. I shouted agreement and gratitude at the TV when Charlie Pickering delivered a segment on the topic a few months ago, and I continue to be heartbroken that people of the world are dropping bombs on each other at vast expense.

I do not pretend to fully understand armed global activity, nor national budgets, but I do know that given a choice between spending time, effort and money on overseas military engagements versus well-thought out nation building projects (Oh. So. Very. Many. To. Choose), I choose the latter. This is not simply throwing money away, rather investing in the future of humanity, of which we are a part.

To be honest, I would prefer blindly giving a bomb’s-worth of food directly to anyone who even *might* be an enemy (in this complicated world of “the enemy of my enemy is, well, a friend of Russia”), than manufacturing, delivering and dropping that bomb upon them, their land, and the people around them.

I hope and trust that you are familiar with the goal of 0.7% GNP going to foreign aid. Please, help us move toward it, not away from it.

On behalf of TEAR Australia, I make the following two concrete requests:

  1. Stop the fourth consecutive cut to Australian aid so that we don’t reach our lowest ever levels of aid.
  2. Start the journey to fulfil our global promise to invest our fair share in a future free from poverty.

I can only assume TEAR Australia has sources indicating that a fourth cut is en route. If not, then I am grateful for small mercies.

(I sent this via http://dearprimeminister.org/ then added the links here.)

Out into the bush

Camping feels like one of those activities that is simply a good idea. City life is varied and interesting, but we only see a very small part of the world every day, and it’s rewarding to do something that takes us elsewhere, both in mind and body.

P1040555

Well, after a few years’ gap, we got out into the bush again. We extracted our camping gear from the back corner of the shed and the spare room cupboard, and went shopping to fill in the gaps. Instant-up tents, now they’re an amazing development, and it’s not a lie: ’tis a very quick job. Finding the Bald Hill campsite in Avon Valley National Park was a pain due to some road layout changes and a rail maintenance area and mine site blocking the way, but after giving up and starting to head home, we found it. Very Zen.

P1040560I was very pleased to see the girls settle into the camping scene very easily. It was simple but well supported car camping, with a drop toilet, a few people nearby, our own stove, and less than 24hrs to make our 20 litres of water last. That said, I have no need to prove a point or beat the elements – just some experience outside of the usual city life, taking the girls along for the ride. They got involved in assembling a stretcher bed, putting a bit of wood on the fire, exploring the area and checking out the view, and even experiencing little differences like limited table space, sitting on logs, keeping dusty feet out of the tent, and enjoying eating and playing with a smaller range of food and toys. We were surprised at how well Hannah enjoyed the entirely different surrounds.

P1040553

Eleanor took this one

After an early night, Eleanor and I were up a little before the rest of the campsite, and it was even quieter than before. We caught sight of a few small birds and a couple of lizards, and did some more exploring together. It was wonderful to drink in the view and listen to the sounds of the bush while wandering about together.