Upgrading PostgreSQL from 9.5.7 to 9.6.3

All commands were done as the root user unless indicated.

This time it was necessary to create a new ZFS hierarchy of filesystems rooted at /var/db/postgres/data96. Also, the new PostgreSQL DBMS runs as the postgres user, not the pgsql user.

# Dump the current database cluster.
su -l pgsql
pg_dumpall | bzip2 -9c > all-db-9.5.7-2017-05-15.sql.bz2
chmod 0400 all-db-9.5.7-2017-05-15.sql.bz2
exit

# Stop the DBMS.
/usr/local/etc/rc.d/postgresql stop

# Configure the new versions.
make -C /usr/ports/databases/postgresql96-server config-recursive

# Upgrade the components using portupgrade.
portupgrade -fpvo databases/postgresql96-client databases/postgresql95-client
portupgrade -fpvo databases/postgresql96-server databases/postgresql95-server
portupgrade -fpvo databases/postgresql96-contrib databases/postgresql95-contrib

# Upgrade everything depending on databases/postgresql96-client.
# Omit the components upgraded in the previous step.
portupgrade -fprv -x databases/postgresql96-client -x databases/postgresql96-server -x databases/postgresql96-contrib databases/postgresql96-client

# Create the new hierarchy.
zfs create zdata/var/db/postgres
zfs create zdata/var/db/postgres/data96
zfs create zdata/var/db/postgres/data96/base
zfs create zdata/var/db/postgres/data96/pg_xlog
zfs set logbias=throughput zdata/var/db/postgres/data96/base
zfs set logbias=throughput zdata/var/db/postgres/data96/pg_xlog
zfs set primarycache=metadata zdata/var/db/postgres/data96/base
zfs set primarycache=metadata zdata/var/db/postgres/data96/pg_xlog
zfs set recordsize=8K zdata/var/db/postgres/data96/base
zfs set recordsize=8K zdata/var/db/postgres/data96/pg_xlog
zfs set redundant_metadata=most zdata/var/db/postgres/data96/base
zfs set redundant_metadata=most zdata/var/db/postgres/data96/pg_xlog
chown -R postgres:postgres /var/db/postgres
chmod -R 0700 /var/db/postgres/data96

# Hide the base and pg_xlog filesystems for now.
zfs unmount zdata/var/db/postgres/data96/base
zfs unmount zdata/var/db/postgres/data96/pg_xlog

# Edit /etc/rc.conf, if necessary, and change postgresql_data to "/var/db/postgres/data96"

# Create the initial database cluster.
/usr/local/etc/rc.d/postgresql initdb

# Rename /var/db/postgres/data96/base and /var/db/postgres/data96/pg_xlog.
mv /var/db/postgres/data96/base /var/db/postgres/data96/base-old
mv /var/db/postgres/data96/pg_xlog /var/db/postgres/data96/pg_xlog-old

# Unhide the two special filesystems.
zfs mount zdata/var/db/postgres/data96/base
zfs mount zdata/var/db/postgres/data96/pg_xlog

# Copy the contents of /var/db/postgres/data96/base-old and /var/db/postgres/data96/pg_xlog-old.
cp -Rp /var/db/postgres/data96/base-old /var/db/postgres/data96/base
cp -Rp /var/db/postgres/data96/pg_xlog-old /var/db/postgres/data96/pg_xlog

# Delete /var/db/postgres/data96/base-old and /var/db/postgres/data96/pg_xlog-old.
rm -R /var/db/postgres/data96/base-old /var/db/postgres/data96/pg_xlog-old

# Start the DBMS.
/usr/local/etc/rc.d/postgresql start

# Copy the old DB dump and change the ownership.
cp -p ~pgsql/all-db-9.5.7-2017-05-15.sql.bz2 ~postgres
chown postgres:postgres ~postgres/all-db-9.5.7-2017-05-15.sql.bz2

# Recreate the old database cluster.
su -l postgres
bzcat all-db-9.5.7-2017-05-15.sql.bz2 | psql -f - template1

# Set a password for the postgres user/role within the database cluster.
psql template1
alter user postgres with password 'somethingsomething';
\q
exit

# Transfer all relevant settings from /usr/local/pgsql/data to /var/db/postgres/data96 for pg_hba.conf and postgresql.conf

# Restart the DBMS.
/usr/local/etc/rc.d/postgresql restart

# Create a new dump of the database cluster.
su -l postgres
pg_dumpall | bzip2 -9c > all-db-9.6.3-2017-05-15.sql.bz2
chmod 0400 all-db-9.6.3-2017-05-15.sql.bz2
exit

# You may now remove the old PostgreSQL hierarchy rooted at /usr/local/pgsql.

devel/py-setuptools27 renamed to devel/py27-setuptools

r436290 renamed devel/py-setuptools27 to devel/py27-setuptools.

Here are four portupgrade commands to make amends:

portupgrade  -ncfpvo devel/py27-setuptools devel/py-setuptools27
portupgrade    -fpvo devel/py27-setuptools devel/py-setuptools27
portupgrade -ncfprvx devel/py27-setuptools devel/py27-setuptools
portupgrade   -fprvx devel/py27-setuptools devel/py27-setuptools

Run similar commands for updating the origin of, say, devel/py-setuptools36 to devel/py36-setuptools.

Upgrading Qt4 and Qt5 after r434380

r434380 made massive changes to Qt4 and Qt5 in FreeBSD. Sadly, there are no instructions on how to upgrade an existing system. The changes to ports/head/UPDATING didn’t help at all. Here are the notes I made while upgrading my laptop running stable/11.

To successfully install misc/qtchooser and upgrade the remaining Qt4 and Qt5 ports, you need to recursively uninstall

  • devel/qt4-linguisttools,
  • devel/qt4-rcc, and
  • devel/qt4-moc.

At some point you to need to upgrade devel/qt5-core before everything else, e.g. portupgrade -fpv devel/qt5-core.

Programmer’s prayer

PROGRAMMER’S PRAYER

Our program, who art in memory,
called by thy name;
thy operating system run;
thy function be done at runtime
as it was in development.

Give us this day our daily output.
and forgive us our code duplication,
as we forgive those who
duplicate code against us.

And lead us not in frustration,
but deliver us from GOTOs.

For thine is the algorithm,
the computation and the solution,
looping forever and ever.

RETURN

Ref.: https://lists.freebsd.org/pipermail/freebsd-questions/2017-January/275982.html. See also https://lists.freebsd.org/pipermail/freebsd-questions/2017-February/276021.html.

CRITICAL_PROCESS_DIED BSOD on Dell XPS 15 9550

Earlier this week, a student walked into my office with his Dell XPS 15 9550 in hand. Sometimes his computer would behave, and sometimes, during heavy load, it would die with a CRITICAL_PROCESS_DIED BSOD. Dell’s own recovery DVD image was unable to restore the computer to a working order. The support personnel at Dell suggested using Microsoft’s Media Creation Tool to download a Windows 10 ISO image. Burning the ISO image to a DVD and reinstalling Windows made the computer runnable to some degree. As soon as we installed the WiFi driver, we got that dreaded CRITICAL_PROCESS_DIED BSOD again. Googling for “Dell XPS 15 9550 CRITICAL_PROCESS_DIED” gave results about the NVMe disk device driver being a possible culprit. This issue has existed for almost a year and are hardly isolated to a few instances. Maybe the XPS 15 9550 model suffers from poor choice of hardware components or bad hardware design.

Yet another technical oriented blog, more or less