MCPcopy
hub / github.com/pocketbase/pocketbase / baseLockRetry

Function baseLockRetry

core/db_retry.go:43–62  ·  view source on GitHub ↗
(op func(attempt int) error, maxRetries int)

Source from the content-addressed store, hash-verified

41}
42
43func baseLockRetry(op func(attempt int) error, maxRetries int) error {
44 attempt := 1
45
46Retry:
47 err := op(attempt)
48
49 if err != nil && attempt <= maxRetries {
50 errStr := err.Error()
51 // we are checking the error against the plain error texts since the codes could vary between drivers
52 if strings.Contains(errStr, "database is locked") ||
53 strings.Contains(errStr, "table is locked") {
54 // wait and retry
55 time.Sleep(getDefaultRetryInterval(attempt))
56 attempt++
57 goto Retry
58 }
59 }
60
61 return err
62}
63
64func getDefaultRetryInterval(attempt int) time.Duration {
65 if attempt < 0 || attempt > len(defaultRetryIntervals)-1 {

Callers 5

execLockRetryFunction · 0.85
deleteMethod · 0.85
createMethod · 0.85
updateMethod · 0.85
TestBaseLockRetryFunction · 0.85

Calls 3

opFunction · 0.85
getDefaultRetryIntervalFunction · 0.85
ErrorMethod · 0.65

Tested by 1

TestBaseLockRetryFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…