SQLite allows having 1 set to MaxOpenConnections (#3941)
* let sqlite have a single concurrent connection
This commit is contained in:
1 parent
fba9d1cdf1
commit
5daef58f54
4 files changed
+33
-3
No files matched your search
@@ -5,6 +5,7 @@ package cache
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -506,3 +507,30 @@ func TestSession(t *testing.T) {
|
||||
assert.ErrorContains(t, rw.LookupById(ctx, lookSess), "not found")
|
||||
})
|
||||
}
|
||||
|
||||
func TestRepository_SqliteReadDuringTx(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
s, err := cachedb.Open(ctx)
|
||||
require.NoError(t, err)
|
||||
rw := db.New(s)
|
||||
|
||||
ret := AuthToken{
|
||||
Id: "something",
|
||||
}
|
||||
assert.ErrorContains(t, rw.LookupById(ctx, &ret), "not found")
|
||||
|
||||
var startTx sync.WaitGroup
|
||||
startTx.Add(1)
|
||||
go func() {
|
||||
_, err = rw.DoTx(ctx, db.StdRetryCnt, db.ExpBackoff{}, func(reader db.Reader, writer db.Writer) error {
|
||||
startTx.Done()
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
|
||||
assert.ErrorContains(t, reader.LookupById(ctx, &ret), "not found")
|
||||
return nil
|
||||
})
|
||||
}()
|
||||
// setup a read that potentially executes during a tx
|
||||
startTx.Wait()
|
||||
assert.ErrorContains(t, rw.LookupById(ctx, &ret), "not found")
|
||||
}
|
||||
Reference in new issue
Block a user