-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reapply 8644 on 9260 #9313
Open
aakselrod
wants to merge
12
commits into
lightningnetwork:yy-beat-itest-optimize
Choose a base branch
from
aakselrod:reapply-8644-on-9260
base: yy-beat-itest-optimize
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+183
−92
Open
Reapply 8644 on 9260 #9313
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
26611ea
go.mod: update btcwallet to latest to eliminate waddrmgr deadlock
aakselrod 6af70e4
go.mod: use local kvdb to reapply removal of global postgres lock
aakselrod 5a55c25
Reapply "kvdb/postgres: remove global application level lock"
aakselrod 82a04f0
log: add sub-logger for kvdb/sqlbase
aakselrod 26564c2
itest: fix flake in multi-hop payments
aakselrod 42afb51
batch: handle serialization errors correctly
aakselrod fa545f1
graph/db: handle previously-unhandled errors
aakselrod feafcc0
sqldb: improve serialization error handling
aakselrod 7f1a72b
Makefile: tune params for db-instance for postgres itests
aakselrod 819bc24
Makefile: log to file instead of console
aakselrod db4bf51
github workflow: save postgres log to zip file
aakselrod 175711a
docs: update release-notes for 0.19.0
aakselrod File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package batch | ||
|
||
import ( | ||
"errors" | ||
"path/filepath" | ||
"sync" | ||
"testing" | ||
"time" | ||
|
||
"github.com/btcsuite/btcwallet/walletdb" | ||
"github.com/lightningnetwork/lnd/kvdb" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestRetry(t *testing.T) { | ||
dbDir := t.TempDir() | ||
|
||
dbName := filepath.Join(dbDir, "weks.db") | ||
db, err := walletdb.Create( | ||
"bdb", dbName, true, kvdb.DefaultDBTimeout, | ||
) | ||
if err != nil { | ||
t.Fatalf("unable to create walletdb: %v", err) | ||
} | ||
t.Cleanup(func() { | ||
db.Close() | ||
}) | ||
|
||
var ( | ||
mu sync.Mutex | ||
called int | ||
) | ||
sched := NewTimeScheduler(db, &mu, time.Second) | ||
|
||
// First, we construct a request that should retry individually and | ||
// execute it non-lazily. It should still return the error the second | ||
// time. | ||
req := &Request{ | ||
Update: func(tx kvdb.RwTx) error { | ||
called++ | ||
|
||
return errors.New("test") | ||
}, | ||
} | ||
err = sched.Execute(req) | ||
|
||
// Check and reset the called counter. | ||
mu.Lock() | ||
require.Equal(t, 2, called) | ||
called = 0 | ||
mu.Unlock() | ||
|
||
require.ErrorContains(t, err, "test") | ||
|
||
// Now, we construct a request that should NOT retry because it returns | ||
// a serialization error, which should cause the underlying postgres | ||
// transaction to retry. Since we aren't using postgres, this will | ||
// cause the transaction to not be retried at all. | ||
req = &Request{ | ||
Update: func(tx kvdb.RwTx) error { | ||
called++ | ||
|
||
return errors.New("could not serialize access") | ||
}, | ||
} | ||
err = sched.Execute(req) | ||
|
||
// Check the called counter. | ||
mu.Lock() | ||
require.Equal(t, 1, called) | ||
mu.Unlock() | ||
|
||
require.ErrorContains(t, err, "could not serialize access") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: It'd be nice to cover batch with a simple unit test to make sure the serialization errors are correctly handled and we don't regress later.