Fixing postgres

When upgrading my Mac, Postgres stopped working. This page documents my journey. First, the migration process gave me a long password for the postgres user. It also didn’t set up Postgres to start up automatically. netstat confirmed nothing running on 5432.

Posgres is started on the old machine using a launch daemon. I can see it at /Library/LaunchDaemons/postgresql-15.plist. Launch daemons require elevated access to run which seems related to the user recreation.

The plist file is a text file so I read it. It says that it runs at load with userName postgres. I ran dscl . list /Users and confirmed that user still exists.

I then came across this post which says I shouldn’t expect the database to start up from a time machine backup. Given that this is just a test database and there’s nothing in there I care about, I tried reinstalling Postgres. Which didn’t change anything.

I then checked /Library/PostgreSQL/15/data/log/<latest> and got:

2023-05-21 07:51:02.282 EDT [372] LOG:  listening on IPv6 address "::", port 5432
2023-05-21 07:51:02.282 EDT [372] LOG:  listening on IPv4 address "0.0.0.0", port 5432
2023-05-21 07:51:02.282 EDT [372] LOG:  listening on Unix socket "/tmp/.s.PGSQL.5432"
2023-05-21 07:51:02.300 EDT [402] LOG:  database system was interrupted; last known up at 2023-04-25 20:00:54 EDT
2023-05-21 07:51:02.667 EDT [402] LOG:  invalid record length at 0/331FC48: wanted 24, got 0
2023-05-21 07:51:02.667 EDT [402] LOG:  invalid primary checkpoint record
2023-05-21 07:51:02.667 EDT [402] PANIC:  could not locate a valid checkpoint record
2023-05-21 07:51:02.668 EDT [372] LOG:  startup process (PID 402) was terminated by signal 6: Abort trap: 6
2023-05-21 07:51:02.668 EDT [372] LOG:  aborting startup due to startup process failure
2023-05-21 07:51:02.668 EDT [372] LOG:  database system is shut down

That was helpful. I reset the log.

JeanneBrskysMBP:bin postgres$ ./pg_resetwal ../data
The database server was not shut down cleanly.
Resetting the write-ahead log might cause data to be lost.
If you want to proceed anyway, use -f to force reset.
JeanneBrskysMBP:bin postgres$ ./pg_resetwal -f  ../data
Write-ahead log reset

After restarting, I saw postgres up again. Yay.

nyjeanne@JeanneBrskysMBP ~ % netstat | grep 5432
222187ba86974afb stream      0      0 222187b5bb6cdf9b                0                0                0 /tmp/.s.PGSQL.5432

And the startup log is happy now.

2023-05-21 08:09:08.930 EDT [374] LOG:  database system is ready to accept connections
2023-05-21 08:14:08.987 EDT [403] LOG:  checkpoint starting: time
2023-05-21 08:14:08.992 EDT [403] LOG:  checkpoint complete: wrote 3 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.002 s, sync=0.001 s, total=0.005 s; sync files=2, longest=0.001 s, average=0.001 s; distance=0 kB, estimate=0 kB

The other problem is that I had removed the database from pgadmin. Luckily this doesn’t delete the database. I registered it again with the same info as the settings on the old mac and all was well. My data is still there too. Nice!

setting up a mac in 2023 from my old mac

My previous Mac only lasted four years. It’s successor made it much longer. At the 8 year mark, the battery was failing. I could have had it replaced for $250, but didn’t thought it was better to get a new machine rather than buy a battery and have the machine need replacement shortly after.

My choice

I had a 15 inch laptop last time, but went with the 13.6 inch. The retina display makes it feel similar, I was pleasantly surprised that the Air was so powerful, especially when adding to it. The specs:

  • Apple M2 chip with 8‑core CPU, 10‑core GPU, 16‑core Neural Engine
  • 24GB unified memory (I had 16 last time)
  • 1TB SSD storage (I had half that before and used a good amount)

Buying the laptop

I went to the store to see the size and feel. I also needed to ask about the difference in colors and compare to my old machine. I went with Space Gray which is a color darker than what I had before.

In the store, they suggested I buy it online so I would know when it comes. (It wound up coming earlier.) I was still able to have it delivered to the store so that was fine.

Other hardware needed

I needed a USB-C to USB-A hub so I could plug in my existing devices. My wired keyboard and wired trackpad still work. I got a hub that also had HDMI so I could plug in my external monitor.

I also got a single USB-C to USB-A adapter so I can continue to use my clicker for presentations.

I still have to set up a security lock. I ordered the Kensington one. There weren’t a lot of choices and it doesn’t let me reuse my existing lock. The new one doesn’t allow closing the lid while the laptop is docked which will take some getting used to.

Setting up the laptop

Time Machine took care of most of the transfer and chip architecture differences. It ran most of the night to transfer all the data. It asks whether you want to start a separate backup or claim the history. I chose the later.

What I had to do:

  1. Cover camera with sticker.
  2. Agree to assorted licenses
  3. Dropbox had me reconfirm
  4. Reinstall key for SnagIt
  5. A lot of setting changes (see next section)
  6. I’ve had the laptop long enough to label it with my phone number and add stickers.
  7. That’s it. Everything else was remembered.

Settings need to reapply

Eight years ago I didn’t need to redo so many settings.

  1. Bring up brightness level to max. Hard to read at default resolution when not bright
  2. Chrome – changed startup settings to remember tabs
  3. Postgres – had to set a new password
  4. A lot of privacy/security settings. Many apps reprompted to get their permissions back

Updating apps

  1. IntelliJ offered to update for the new chip.
  2. Eclipse needed a reinstall with AArch 64 (my Eclipse was from 2021 though – I use a mix of IntelliJ and Eclipse). The installer noted I have a lot of Java versions installed and complained about the signatures for some. I chose cancel and it proceeded. I also had to delete the .m2 cache because Eclipse prompted me it wasn’t compatible.
  3. Zoom offered to update for the new chip
  4. I had to re-install BeFocusedPro to get it to be in the menu bar. It remembered I paid already at least.
  5. I installed 1Password 8. I don’t think this was necessary, but I couldn’t figure out the settings to have it open web pages in 1Password 7. And I would have upgraded soon anyway. I also needed to set up Universal Autofill on Mac so I could use command + \. (It used to automatically prompt me to use 1Password. I like the keyboard shortcut though)

Postgres

This was a lot so gets its own post.

Specialist appointment

Apple encourages a free online appointment with a “specialist” to go over new features. I did that and learned a few things.

Touch Id

The built in keyboard has physical keys. (not the touchbar of the past; glad I missed that model.) On the top right (next to F12) is a touch key for touch id. (My old machine had a power button there) So far, I’ve used it for 1Password, unlocking after initial bootup for the day and Apple settings. I also set up a second finger to work with touch id.

Twitter

I can’t logon to Twitter using the official app. It still remembers me as @jeanneboyarsky and asks for a password to verify my identity. Then gives an error. I tried uninstalling and reinstalling. My browser session still works so I’m afraid to change my password to see if that fixes. It’s not a big deal to use the web app. I mainly browse on my phone/tablet, so it is only for posting on the computer anyway.

setting up my new mac from my old mac

My previous Mac turned four years old recently and failed. The Apple store looked at it when it started failing and couldn’t find anything wrong. Then two days later, it died all together. The next step was to send it offsite and hope they could fix it. This would have been the second time my Mac would be out of my possession in the same year. (The first was for an issue with 2011 machines that they fixed for free, but took a week)  I decided to buy a new Mac rather than pay a decent percentage of the cost of a new machine and hope they could fix it. I would have replaced the machine in another year or two anyway so decided to start over clean. I am happy with going back to Mac. I didn’t have a series of small problems like I had on Windows. (Just the big one). I didn’t have to deal with viruses. I had a real UNIX command line.

My choice

I had a 15 inch laptop last time and wanted to stay with that.I chose the higher end of the two 15 inch choices. This is the first time I’ve bought a laptop without adding RAM. (Adding RAM wasn’t an option). The specs:

  • 2.5 GHz quad-core Intel Core i7 processor (Turbo Boost up to 3.7GHz)
  • 512 GB flash storage (I used a little under 256GB on my old machine. I started researching laptops when the machine started showing symptoms so I knew this before it died)
  • 16GB 1600MhZ RAM

Buying the laptop

Since I wasn’t customizing anything, I was able to buy the laptop in the same visit to the store where they confirmed my old laptop was dead. This was in the evening (about 9pm) because I went after being at Maker Faire all day. When I gave the Apple sales rep my credit card, it came back as declined. I’m puzzled because I used it earlier in the day. Luckily the Apple employee wasn’t puzzled. Apparently this happens often. She said multiple credit card companies view a large purchase “late at night” from an electronics store to be suspicious. I called and she was right. The credit card company asked me two security questions. The first I knew. The second was “what is your username for online access to your credit card account.” I have no clue. At the time, that information is in autocomplete on my old computer! (and in a Time Machine backup.) Luckily they asked me a third question. Gotta love security questions that even the authorized person knows the answer to.

Setting up

Time Machine is awesome! All my programs and data automatically showed up. It even remembered which sites I was logged into and what was open when the computer died. I didn’t even have to turn Time Machine back on. It just kept updating from the new computer. I did say that I wasn’t going back to the old computer and not worry about backward compatibility.

I had to reset some of the settings:

  1. Pair trackpad. (I have a wired keyboard).
  2. Cover camera with sticker.
  3. Sign back into Dropbox. I was prompted for my two factor credentials.
  4. Turn off notifications for IM. (I don’t like getting a visual notification) Or more specifically change alert style to “none” for everything. I leave the sound on so I know about it.
  5. Turn on firewall.
  6. Agree to XCode license. I was prompted with “Agreeing to the Xcode/iOS license requires admin privileges, please re-run as root via sudo” on my first git pull. I think this was coincidence as there was an XCode update right around the time I changed laptops.
  7. Re-enter product key for Office. (Oddly the Windows 8 in my VM didn’t ask for the product key again)
  8. That’s it. Everything else was remembered.

I just have to label the laptop, but I want to wait one more week for that – until the return period passes.

The missing feature – locks

I have a Kensington combination lock for my laptop. Granted anyone with a power tool (wire cutter or saw) could still steal it. But that takes longer and makes it less likely that a maintenance/delivery person could just swipe it. Apple got rid of the place to plug in the lock. They also got rid of the DVD player, but I don’t use that.

I bought the KTech Bracket which you attach to the laptop and has an adapter to plug the existing lock into. The bracket was easy to attach. The idea is that you unscrew four screws from the laptop and rescrew their longer ones with the product in between. They even give you a screwdriver. I managed to lose one of the screws, but KGear said they will mail me a replacement. I’m not thrilled about the need for a product like this in the first place. Now you just need a screwdriver rather than a wire cutter/saw to disconnect the laptop from the lock. I’m disappointed Apple got rid of this feature from the body of the laptop.