This is an automated email from the ASF dual-hosted git repository.

laskoviymishka pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iceberg-go.git


The following commit(s) were added to refs/heads/main by this push:
     new e0a934a6b test(catalog/sql): queue SQLite writers on a busy timeout in 
the shared test DSN (#2545)
e0a934a6b is described below

commit e0a934a6b6478e975cd7d8b008cafa8fba15f5a3
Author: Sylwester Lachiewicz <[email protected]>
AuthorDate: Mon Nov 16 08:48:45 2026 +0100

    test(catalog/sql): queue SQLite writers on a busy timeout in the shared 
test DSN (#2545)
    
    The two concurrent table/view collision tests and the ubuntu CI runners
    still surfaced SQLITE_BUSY (database is locked) instead of the catalog
    sentinels because the losing writer's retry budget ran out before the
    winner committed, as seen in PR #2376's run 42457673447. Issue #1793
    tracks the sibling sentinel test hitting the same error since August.
    
    Put the busy timeout in the file-backed SQLite DSN the whole suite
    shares, as the NewCatalog documentation already prescribes for callers
    with concurrent writers: every pooled connection now waits for the
    competing writer instead of erroring. sqliteshim selects mattn (cgo) or
    modernc, whose DSN parameters differ, so branch on
    sqliteshim.DriverName().
    
    TestCreateNamespaceConcurrent already appended busy_timeout to the DSN
    per kevinjqliu's analysis in #1793; it now inherits it from the shared
    DSN instead.
    
    Fixes #1793
    
    Signed-off-by: Sylwester Lachiewicz <[email protected]>
---
 catalog/sql/sql_test.go | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/catalog/sql/sql_test.go b/catalog/sql/sql_test.go
index fb10b4468..5ff6ed591 100644
--- a/catalog/sql/sql_test.go
+++ b/catalog/sql/sql_test.go
@@ -28,7 +28,6 @@ import (
        "io"
        "maps"
        "math/rand/v2"
-       "net/url"
        "os"
        "path/filepath"
        "slices"
@@ -176,8 +175,14 @@ func (s *SqliteCatalogTestSuite) SetupTest() {
        s.Require().NoError(err)
 }
 
+// catalogUri returns the file-backed SQLite DSN the whole suite shares, with a
+// busy timeout on every pooled connection; mattn and modernc both read
+// _busy_timeout. The timeout applies where SQLite consults the busy handler: a
+// lock requested before the transaction has read anything. A transaction that
+// reads first and then writes fails with SQLITE_BUSY at once, whatever the
+// timeout.
 func (s *SqliteCatalogTestSuite) catalogUri() string {
-       return "file://" + filepath.Join(s.warehouse, "sql-catalog.db")
+       return "file://" + filepath.Join(s.warehouse, "sql-catalog.db") + 
"?_busy_timeout=5000"
 }
 
 func (s *SqliteCatalogTestSuite) confirmNoTables(db *sql.DB) {
@@ -2862,10 +2867,11 @@ func (s *SqliteCatalogTestSuite) 
TestCreateNamespaceConcurrent() {
        // gets ErrNamespaceAlreadyExists, not the driver's duplicate-key error.
        const writers = 8
 
-       // A busy timeout so the writers queue on the sqlite lock instead of 
failing
-       // with SQLITE_BUSY, which is a different contention problem to this 
one.
+       // The shared catalogUri() DSN carries a busy timeout, so the writers 
queue
+       // on the sqlite lock instead of failing with SQLITE_BUSY, which is a
+       // different contention problem to this one.
        loaded, err := catalog.Load(context.Background(), "default", 
iceberg.Properties{
-               "uri":             s.catalogUri() + "?_pragma=" + 
url.QueryEscape("busy_timeout(10000)"),
+               "uri":             s.catalogUri(),
                sqlcat.DriverKey:  sqliteshim.ShimName,
                sqlcat.DialectKey: string(sqlcat.SQLite),
                "type":            "sql",

Reply via email to