fix: replace named locks with Galera-compatible row locks
Test / test (push) Successful in 25m39s
Build and publish image / image (push) Successful in 16m16s

This commit is contained in:
bryanpedini committed 2026-11-20 16:27:15 +01:00
1 parent ee07866d1c
commit 65d16c2fc6
22 files changed
+314 -365

No files matched your search

+15 -17
View File
@@ -344,28 +344,28 @@ func TestIntegrationZoneAPIHandlers(t *testing.T) {
func TestIntegrationZoneAPILockTimeout(t *testing.T) {
it := newITZoneAPI(t)
it.call(t, it.admin, "zone_create", "", "", zoneAPITestCreate, 201)
conn, err := it.db.root.Conn(t.Context())
ctx := t.Context()
tx, err := it.db.root.BeginTx(ctx, nil)
if err != nil {
t.Fatal(err)
}
defer conn.Close()
lock, err := acquireNamedLock(t.Context(), conn, it.server.tables.zoneLockName(zoneAPITestName), 0)
if err != nil {
defer tx.Rollback()
tables := it.server.tables
if _, err := tx.ExecContext(ctx, tables.sql(zoneLockSQL), tables.zoneLockName(zoneAPITestName)); err != nil {
t.Fatal(err)
}
defer func() {
if err := lock.release(t.Context()); err != nil {
t.Error(err)
}
}()
ctx, cancel := context.WithTimeout(t.Context(), zoneLockTimeout+5*time.Second)
ctx, cancel := context.WithTimeout(ctx, zoneLockTimeout+5*time.Second)
defer cancel()
start := time.Now()
c := it.request(it.admin, "record_create", "", "", zoneAPITestRecord)
_, err = zoneAPITestCall(ctx, c)
var apiErr *apiError
if !errors.As(err, &apiErr) || apiErr.Status != http.StatusServiceUnavailable || apiErr.Message != "zone busy" {
t.Fatalf("contended write error = %v", err)
}
if waited := time.Since(start); waited < zoneLockTimeout-time.Second || waited > zoneLockTimeout+3*time.Second {
t.Fatalf("contended write waited %v", waited)
}
it.audit(t, "record_create", 0)
it.serial(t, newSOASerial(modelNow))
}
@@ -690,7 +690,7 @@ func TestIntegrationDelegationZoneLock(t *testing.T) {
c := it.request(it.admin, operation, "", "", "")
c.Vars["username"] = it.user.Username
result := make(chan error, 1)
err := withZoneLock(t.Context(), it.server.db, it.server.tables, zoneAPITestName, it.server.log, func(conn *sql.Conn) error {
err := runZoneTx(t.Context(), it.server.db, it.server.tables, zoneAPITestName, it.server.log, func(tx *sql.Tx) error {
go func() {
var err error
if operation == opDelegationGrant {
@@ -705,13 +705,11 @@ func TestIntegrationDelegationZoneLock(t *testing.T) {
return fmt.Errorf("delegation did not wait for zone lock: %v", err)
case <-time.After(200 * time.Millisecond):
}
return runInTx(t.Context(), conn, func(tx *sql.Tx) error {
if _, err := newDelegationStore(tx, it.server.tables).DeleteZoneDelegations(t.Context(), zoneAPITestName); err != nil {
return err
}
_, err := newRecordStore(tx, it.server.tables).DeleteZoneRecords(t.Context(), zoneAPITestName)
if _, err := newDelegationStore(tx, it.server.tables).DeleteZoneDelegations(t.Context(), zoneAPITestName); err != nil {
return err
})
}
_, err := newRecordStore(tx, it.server.tables).DeleteZoneRecords(t.Context(), zoneAPITestName)
return err
})
if err != nil {
t.Fatal(err)