AWS driver: initDB fails with MySQL 1205 while a running instance holds coordination-row locks across S3/witness I/O
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
Research direction
Start in storage/aws/aws.go at mySQLSequencer.initDB, around L1018 and L1040–1060, then trace publishCheckpoint and consumeEntries where FOR UPDATE spans f(...). Reproduce with two instances and delayed S3 or witness I/O; done means a second NewAppender no longer times out with MySQL 1205 while the first instance is active.
Written by the indexing model from the issue text.
Description
Summary
With the AWS storage driver, a new process can fail to start while another instance of the same log is running, whenever that instance's S3 or witness I/O is slow. The new process's initDB blocks on coordination-table row locks that the running instance holds FOR UPDATE across network I/O. After InnoDB's lock wait (innodb_lock_wait_timeout, 50s by default), NewAppender fails with:
failed to init appender lifecycle: failed to create MySQL sequencer: failed to initDB: Error 1205 (HY000): Lock wait timeout exceeded; try restarting transaction
Observed on v1.0.3. The relevant code is unchanged on v1.0.4 and on main.
Mechanism (storage/aws/aws.go)
At every startup, mySQLSequencer.initDB does two things (main, around L1018 and L1040–1060):
ALTER TABLE PubCoord ADD COLUMN size ..., expectingER_DUP_FIELDNAME;INSERT IGNORE INTOeach coordination table (Tessera,SeqCoord,IntCoord,PubCoord,GCCoord).
The INSERT IGNORE on an existing row takes a lock on that row, and the ALTER TABLE needs a metadata lock on PubCoord.
Running instances hold those rows FOR UPDATE while calling out:
publishCheckpointtakesSELECT publishedAt, size FROM PubCoord WHERE id = ? FOR UPDATE, then runsf(ctx, fromSeq, rootHash)before commit. That call builds, signs and witnesses the checkpoint and writes it to object storage.consumeEntriestakesSELECT seq, rootHash FROM IntCoord WHERE id = ? FOR UPDATE(plusSeq ... FOR UPDATE), then runsf(ctx, fromSeq, entries), which integrates and writes tiles and bundles to object storage, before commit.
So any stall in that I/O extends the lock hold, and a starting instance's initDB waits on it. In our case, S3 requests were being rejected with RequestTimeTooSkewed for about 15 minutes. Every new instance started during that window failed with 1205 and crash-looped until the I/O recovered.
Repro sketch
- Run one instance of a log on the AWS driver, with a steady trickle of
Adds so that integration and publication run. - Make object-storage writes slow, for example by injecting delay into the S3 client or at the network. The goal is for the
f(...)insideconsumeEntries/publishCheckpointto take longer thaninnodb_lock_wait_timeout. - Start a second instance against the same DB.
NewAppenderreturns the 1205 error above after about 50s.
Suggestions (either would fix it for us)
- Make
initDBlock-free when the schema already exists. Checkinformation_schema.COLUMNSbefore theALTER TABLE. Replace the unconditionalINSERT IGNOREs with a read (SELECT 1 ... WHERE id = 0, which needs no row lock under InnoDB consistent reads), and insert only when the row is missing. Then a started instance never contends with a running one. - Or release the coordination row locks before the network I/O, for example with an optimistic compare-and-set on the row after
f()completes, so the lock span is bounded by DB latency rather than object-storage or witness latency. That is a bigger change, but it would also bound contention between concurrent running instances.
We're working around it downstream by retrying NewAppender on 1205 with a short backoff. That only helps if the lock clears within the caller's startup budget. Happy to test a fix.
- Dominant language
- Go
- Stars
- 262
- Forks
- 64
- Avg merge
- 1d 6h
- Merged PRs (30d)
- 20
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from transparency-dev/tessera
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
transparency-dev/tessera#1286 ·
Maintainers usually reply within 1 day
-
TestPosixMirrorIntegration fails on macOS: its burst of connections overflows the listen queuePossibly taken @grempe claimed this 30 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
transparency-dev/tessera#1253 ·
Maintainers usually reply within 1 day
-
Fix tlog-mirror log origin length prefixPossibly taken @phbnf claimed this 32 days ago. Openenhancement
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
transparency-dev/tessera#1233 · 1 comment ·
Maintainers usually reply within 1 day
-
AWS: adds fail while object-storage writes are slow (integration's gap lock on Seq)Possibly taken @grempe claimed this 30 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 35/100
transparency-dev/tessera#1256 ·
Maintainers usually reply within 1 day
-
AWS: MySQL pools are never closed, so reopening a log in one process leaks goroutines and connectionsPossibly taken @grempe claimed this 13 days ago. Open
Difficulty 4/5 1-2 days Newbie friendliness 48/100
transparency-dev/tessera#1251 · 1 comment ·
Maintainers usually reply within 1 day
All issues in transparency-dev/tessera
Similar issues
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 2 days
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
seaweedfs/seaweed-block#443 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
version-fox/vfox#825 ·
Maintainers usually reply within 1 day
-
HTTP `batch.Send` returns nil and inserts no rows when the block does not encodePossibly taken @Indian-boult claimed this today. Openbug queries
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
ClickHouse/clickhouse-go#2155 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 82/100
Maintainers usually reply within 1 day