slachiewicz opened a new pull request, #2589:
URL: https://github.com/apache/iceberg-go/pull/2589

   Fixes #1793.
   
   The SQL catalog's write transactions check the namespace and identifier 
before they insert. database/sql begins SQLite transactions as DEFERRED, and 
SQLite never calls the busy handler when a transaction that has already read 
asks for the write lock. So `busy_timeout` had no effect, and a writer that 
found the lock held got `SQLITE_BUSY` once the ~310 ms retry budget ran out. 
That is the failure `TestConcurrentTableViewCollisionUnderLockContention` hits 
on loaded runners.
   
   On SQLite, write transactions now start with a write that matches no rows, 
so the lock is requested before any read and writers queue on `busy_timeout`. 
Other dialects are unchanged.
   
   - **Lock timeouts are not retried.** When SQLite has already waited out 
`busy_timeout`, `retrySerializableWriteTx` returns the error instead of waiting 
again on each attempt. With a busy timeout of 0 the existing retry budget 
applies as before.
   - **A context deadline caps the wait.** Neither driver interrupts the busy 
handler when the context ends, so each write transaction runs on its own pooled 
connection, lowers `busy_timeout` to the time left before the deadline, and 
restores it afterwards. A cancellation without a deadline still waits out 
`busy_timeout`.
   
   The driver defaults now matter. mattn sets a 5000 ms busy timeout when the 
DSN names none, so on cgo builds a contended write waits up to 5 s where it 
used to fail within about 310 ms. modernc sets none, so its behaviour without a 
DSN setting is unchanged. The `NewCatalog` doc now says this.
   
   SQLite write transactions are also serialized from their first statement. 
Paths that used to return a sentinel straight from a read, such as creating an 
identifier that already exists, dropping a missing table, or a commit that 
loses its compare-and-swap, now wait for a concurrent writer first. The two 
namespace-race tests and `TestUpdateViewRejectsCompetingCommit` assumed two 
SQLite writers could be inside their transactions at once; they now cover both 
serialized orders instead.
   
   #2545 sets a busy timeout in the shared test DSN. It complements this change 
and refers to #1793 rather than fixing it.
   
   Verified: `go test -race ./catalog/sql/` on modernc and on mattn (`-tags 
cgosqlite`) → pass; `TestCreateWaitsOnBusyTimeoutWhileWriteLockHeld` on main → 
fails with the CI message.
   
   I have run this on macOS only, not on Linux or against the Postgres, MySQL, 
MSSQL or Oracle integration setups.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to