← who art thou
Network Working Group
Saksham Srivastava
Reworking Fundamentals in Computing: 0007
saksh.fyi
Category: Informational
November 2026

Lock, Stock and One Dead Pod

Status of This Memo #

This memo provides information for the curious and the on-call. It does not specify an Internet standard of any kind. Distribution of this memo is unlimited, and comments are welcome by email (saksh.am [at] outlook [dot] in). I don’t trust comment boxes online.

Abstract #

A deploy failed because a column didn’t exist. The migration that adds it had never run, because Liquibase’s lock had been held for 24 days by a pod that was long dead. This memo is about why that can happen at all (a Liquibase lock is a row, not a lock), how a slow index build and a Kubernetes startup probe got us there, and how we got out.

Table of Contents #

1. Introduction #

Like RFC 0003, this one is not theory. It happened last night on a two-hour call, and I’m writing it down before I forget the fun parts.

The short version: Liquibase started building some indexes, the pod got killed before it could let go of its lock, and every migration after that waited on a lock nobody was holding. For 24 days. Nothing complained until new code went looking for a column that wasn’t there.

2. The Symptom #

We were doing a deploy, and the new code started failing with this (names swapped for stand-ins):

ERROR: column "some_new_column" does not exist

The column comes from a migration. So, did the migration run? Liquibase writes one row per applied changeset into a table called databasechangelog, so you can just ask:

select id, dateexecuted from databasechangelog order by orderexecuted desc limit 3;
 id  |        dateexecuted
-----+----------------------------
 155 | 2026-10-23 19:33:32.799652
 154 | 2026-10-23 19:33:32.772172
 153 | 2026-10-20 14:09:16.659993

(Changeset names trimmed to their numbers.) The one we needed was 161. Nothing had run since 23 October.

Okay, so why did Liquibase just… stop?

It hadn’t stopped. It was waiting:

select * from databasechangeloglock;
id | locked |        lockgranted         |     lockedby
---+--------+----------------------------+-------------------
 1 | t      | 2026-10-23 19:33:32.582197 | some-pod (some-ip)

Locked a fraction of a second before 154 and 155 ran, by a pod that hadn’t existed for weeks.

3. A Liquibase Lock Is Just a Row #

Say two pods of the same service start at once. Both would try to run the same migrations, so they need to take turns.

Think of a “do not disturb” sign on a hotel room door. You hang it when you go in and take it off when you leave. Now picture a guest who leaves through the window. The sign stays up, and housekeeping waits outside forever.

That is roughly what Liquibase does [LB-LOCK]. The “lock” is one row in a table, and taking it is an ordinary update. Simplified:

-- take the lock: only one pod's update can match
update databasechangeloglock
   set locked = true, lockgranted = now(), lockedby = 'my-host (my-ip)'
 where id = 1 and locked = false;
-- (commits straight away)

-- ... run the changesets ...

-- release it, from a finally block in the JVM
update databasechangeloglock set locked = false, lockgranted = null, lockedby = null where id = 1;

And if that last update never runs?

Then the row says locked = true forever. The first update committed ages ago, and Postgres has no idea that row has anything to do with the connection that wrote it. It is not a Postgres lock. It doesn’t go away when the connection closes, or when the pod dies, or even when Postgres restarts. Ours did restart, five days later. The row didn’t care.

Everyone else who wants the lock polls the row, by default for up to 5 minutes, and then gives up with Could not acquire change log lock [LB-PARAMS].

4. How It Got Stuck #

pod takes the lock (a row update, committed)
  └─► two quick changesets
        └─► five trigram indexes, CREATE INDEX CONCURRENTLY, one after another
              └─► ~140 s in, the startup probe gives up → SIGTERM → SIGKILL
                    └─► the finally block never runs → locked = true stays
                          └─► every new pod waits on the row, gets killed first, repeat

The index build was slower than the probe. CREATE INDEX CONCURRENTLY doesn’t block writes to the table, and that is exactly what makes it slow [PG-CIC]. It scans the table twice instead of once. It also has to wait for every transaction that could touch the index to finish, so one session from some other service sitting idle in transaction can hold it up for minutes. And trigram GIN indexes are heavy to build: every value gets chopped into three-letter pieces and each piece is indexed [PG-TRGM]. The tables were around 700 MB each.

Five of those, back to back. The pod got about 140 seconds before the startup probe gave up on it.

The kill skipped the cleanup. When a startup probe fails, the kubelet kills the container: SIGTERM, a grace period, then SIGKILL [K8S-PROBES]. A SIGKILLed JVM runs nothing. A JVM that gets SIGTERM runs its shutdown hooks and exits, but the main thread is stuck inside a JDBC call waiting on Postgres, and it never gets unwound. So Liquibase’s finally never runs. The guest left through the window.

Wait, so did the index builds die with the pod?

Not sure, and this bit is a little odd. When we looked, all five indexes existed and none were invalid (a concurrent build that fails part way leaves an INVALID index behind [PG-CIC]). By default Postgres only notices a client is gone when it next tries to talk to it, so a long build can keep going and finish after the pod that started it is dead. That would fit. We haven’t confirmed it, and we haven’t checked why the changeset that built them isn’t in databasechangelog either.

Every pod after that hung quietly. New pods sat polling the row, happy to wait the full 5 minutes before throwing that nice, clear “could not acquire change log lock” error. But the probe killed them at about 140 seconds. They never got to say it. They just restarted, again and again, without the one log line that would have explained everything.

It is not a slow startup. It is a startup waiting for someone who is never coming back.

5. The Fix #

So just set it back to false?

Yes, but only once you’re sure nobody is actually using it. Clear a lock that a live migration still holds and now you have two migrations running at once. So first we checked:

Nobody home. Then one update, with a where clause that only matches the exact stuck state, so it does nothing if something changed in the meantime:

update databasechangeloglock set locked = false, lockgranted = null, lockedby = null
where id = 1 and lockedby like 'some-pod%';

The service also kept its own “migration in progress” flag, written at the start and meant to be cleared at the end. Same story, same window. We marked that one failed so the service would try again.

Within a few minutes the next run picked everything up and finished. Twenty-four days of migrations, in one go.

Liquibase has a command for this, liquibase release-locks [LB-RELEASE]. It doesn’t check who holds the lock, so do the checks above first either way.

6. What Would Have Stopped It #

None of this is done yet. These are options, not decisions.

7. Caveats #

8. Conclusion #

The TL;DR: a pod died between “take the lock” and “release the lock”, and the lock was a row, so it didn’t die with it.

And back to RFC 0001: for 24 days, nothing failed loudly. Pods restarted, migrations didn’t run, and the first thing that actually said anything was a missing column. 🤦

9. References #

[LB-LOCK] Liquibase documentation, “DATABASECHANGELOGLOCK table”, docs.liquibase.com.

[LB-PARAMS] Liquibase documentation, “Liquibase Parameters” (changelog-lock-wait-time-in-minutes), docs.liquibase.com.

[LB-RELEASE] Liquibase documentation, “release-locks”, docs.liquibase.com.

[PG-CIC] PostgreSQL documentation, “CREATE INDEX” (Building Indexes Concurrently), postgresql.org/docs.

[PG-TRGM] PostgreSQL documentation, “pg_trgm”, postgresql.org/docs.

[K8S-PROBES] Kubernetes documentation, “Configure Liveness, Readiness and Startup Probes”, kubernetes.io/docs.

[K8S-INIT] Kubernetes documentation, “Init Containers”, kubernetes.io/docs.

[RFC0001] Saksham, “Observability, My Dear Watson”, blogs.saksh.fyi.

[RFC0003] Saksham, “They Did Surgery on a Process”, blogs.saksh.fyi.