At 13:58 UTC on Monday 30 November 2026, sign-in on Hanko Cloud started taking longer than usual. Registration slowed. Session validation slowed. The user profile endpoint slowed. The console slowed.
Nothing had crashed. No deploy had just landed. Traffic had simply risen above normal.
Forty nine minutes later, at 14:47 UTC, traffic fell back to normal and the service recovered on its own. The fix came the next morning. It was not a new server, a bigger database, or a code rewrite. It was six indexes.
Hanko published the full account on 2 December. It is a short postmortem, and it is worth reading slowly, because the failure has two separate lessons. One is about how PostgreSQL uses an index. The other is about what a health check actually checks.
First, the plain words
Hanko is an authentication service. Other applications use it to handle sign-in, registration, and sessions, so they do not have to build that themselves.
When Hanko loads a full user, it does not read one row and stop. It runs several queries to fetch related records: the user's email addresses, their WebAuthn credentials, and more. WebAuthn is the standard behind passkeys and security keys. The credential record is what lets a user prove they hold the right key.
Two of those queries looked like this in shape:
SELECT ... FROM emails WHERE user_id IN (...);
SELECT ... FROM webauthn_credentials WHERE user_id IN (...);
That is an ordinary lookup. Give me the rows that belong to these users.
An index is a sorted shortcut the database keeps beside a table. Think of the index at the back of a book. Without it, finding every mention of one name means reading every page. With it, you look up the name and jump straight to the right pages.
A sequential scan is the reading every page version. PostgreSQL reads the whole table, row by row, and keeps the rows that match. On a small table that is fine. On a large table, under load, it is slow and it burns CPU.
A composite index is an index built on more than one column, in a set order. For example, an index on (id, user_id) sorts first by id, then by user_id within each id. That order matters, and it is where this story turns.
The index that existed and did not help
Hanko's review found two different problems behind the two slow queries.
On the emails table, there was no index on user_id at all. A lookup by user_id had no shortcut. PostgreSQL read the whole table.
On the webauthn_credentials table, there was an index, and it still did not help. user_id was the second column of an index that starts with id. The query filtered only on user_id. It said nothing about id.
Here is why that fails. An index on (id, user_id) is sorted by id first. All the rows for one user_id are scattered across the index, grouped under many different id values. There is no single place to jump to. PostgreSQL can sometimes scan the whole index instead of the whole table, but it cannot use that index for a direct lookup on the second column alone. In Hanko's words, that index "did not provide an efficient lookup for the query filtering only on user_id."
This is the part that catches people. The schema looks covered. Someone checking quickly sees an index that mentions user_id and moves on. The database sees an index whose first column the query never mentions, and falls back to reading the table.
When traffic rose at 13:58, Hanko ran more of these full scans. The two queries became the main contributors to database CPU load. Every sign-in paid for a full table read, twice.
The review then found four more lookups on the same load path with the same shape: identities.user_id and identities.email_id had no indexes, and webauthn_credential_transports.webauthn_credential_id and user_custom_claims.user_id appeared only as the second column in composite indexes. Six gaps in total, all on the path that loads a user.
The check that stayed green
The second lesson is about detection.
Hanko's status page probe calls /status. That endpoint reads signing keys from a small database table. During the incident, that query kept succeeding. So the probe kept reporting health while sign-in was slow.
The probe never exercised the user-load path. It never measured how long a sign-in or a session validation took. Internal monitoring did not alert either. Hanko says a monitoring misconfiguration left them without the data to even quantify the slowdown. They could not determine how many projects or users were affected.
A customer told them. Nineteen minutes after the slowdown began, at 14:17, a customer reported that some of their users could not sign in. Hanko posted the incident on the status page at 14:33. By 14:47 traffic had eased and performance recovered. The team identified the two lookups as the main CPU consumers at 14:57 and the index gaps at 15:14.
No data was lost or exposed. That matters, and Hanko says it plainly.
The next morning, Tuesday 1 December at 09:41 UTC, Hanko deployed a PostgreSQL migration adding the six indexes. Database CPU dropped sharply after the deploy and stayed lower. One honest detail from the postmortem: the migration builds the indexes without CONCURRENTLY, so if you self-host Hanko, writes to each affected table may pause while its index builds. Worth knowing before you upgrade a large table.
How to catch this in your own schema
You do not need Hanko's traffic to have Hanko's bug. You need a table, a lookup by a foreign key, and an index that starts with the wrong column. Here are two small guards.
First, ask PostgreSQL what plan it would actually use. EXPLAIN shows the plan without running the query. If the plan says Seq Scan on a large table for a lookup by one column, you have found the problem before your users do.
Second, check that every column you filter on by itself is the first column of some index. This Python script reads the index definitions from PostgreSQL's catalog and flags lookups whose column is missing or buried second.
import psycopg # psycopg 3
# Columns your code filters on alone, table by table.
LOOKUPS = {
"emails": ["user_id"],
"webauthn_credentials": ["user_id"],
"identities": ["user_id", "email_id"],
}
def leading_columns(conn, table):
rows = conn.execute(
"""
SELECT indexdef FROM pg_indexes
WHERE schemaname = 'public' AND tablename = %s
""",
(table,),
).fetchall()
leaders = set()
for (indexdef,) in rows:
# indexdef looks like: CREATE INDEX x ON public.t USING btree (id, user_id)
cols = indexdef.split("(", 1)[1].split(")", 1)[0]
first = cols.split(",")[0].strip().strip('"')
leaders.add(first)
return leaders
with psycopg.connect("dbname=app") as conn:
problems = []
for table, columns in LOOKUPS.items():
leaders = leading_columns(conn, table)
for col in columns:
if col not in leaders:
problems.append(f"{table}.{col} is not the first column of any index")
for p in problems:
print("MISSING:", p)
raise SystemExit(1 if problems else 0)
Run it in CI against a database built from your migrations. It fails the build when a lookup column is absent or second in line.
Then add a boundary test with the three shapes that decide this bug:
- Filter on the first column only, for example
WHERE id IN (...). The plan should use the index. - Filter on the second column only, for example
WHERE user_id IN (...). Before the fix, this is the sequential scan. After you add a dedicated index, it should use the new index. - Filter on both columns. The plan should use the composite index.
Assert on the plan text from EXPLAIN, not on timing. Timing on a test machine with twelve rows tells you nothing. The plan tells you which path PostgreSQL will take when the table is large.
One warning from Hanko's own fix applies to yours too. Building an index on a large, busy table can pause writes. PostgreSQL offers CREATE INDEX CONCURRENTLY for exactly that case. It is slower to build and cannot run inside a transaction block, but it lets writes continue. Decide which trade you want before the incident decides for you.
Make the health check walk the real path
The other guard is a probe that does what a user does. Hanko says a synthetic check that exercises sign-in or session validation is a further option they are considering. A synthetic check is a small automated request your own system makes on a schedule, shaped like real traffic, so you find out before a customer does.
In Go, the shape is simple. Time the real endpoint, and alert on the time, not just on whether it answered.
package main
import (
"fmt"
"net/http"
"time"
)
func checkSessionValidation(url, token string) error {
start := time.Now()
req, err := http.NewRequest(http.MethodGet, url, nil)
if err != nil {
return err
}
req.Header.Set("Authorization", "Bearer "+token)
resp, err := http.DefaultClient.Do(req)
if err != nil {
return err
}
defer resp.Body.Close()
elapsed := time.Since(start)
if resp.StatusCode != http.StatusOK {
return fmt.Errorf("status %d after %s", resp.StatusCode, elapsed)
}
if elapsed > 2*time.Second {
return fmt.Errorf("slow: %s", elapsed)
}
return nil
}
The threshold is yours to set. The point is that the check loads a user the way sign-in does, through the same queries, and fails when that path gets slow. A probe that reads a small table will keep passing while the path your users depend on falls over. That is exactly what happened here.
What to take from forty nine minutes
Hanko's slowdown ended by itself when traffic eased. The indexes the next morning are what stop it coming back. The postmortem is short, specific, and honest about the two blind spots: a schema where user_id looked indexed but was not usable, and monitoring that never touched the failing path.
Both blind spots are cheap to check today. List the columns your code filters on alone. Confirm each one leads an index. Run EXPLAIN on those lookups and read the plan. Then point one synthetic check at the endpoint your users actually hit, and alert on how long it takes.
Have you ever found an index in your schema that mentioned the right column but could not be used for the query you were running?
Source: Hanko, "Hanko Cloud incident postmortem for November 30, 2026", published 2 December 2026. https://www.hanko.io/blog/hanko-cloud-incident-postmortem-for-november-30-2026
Top comments (0)