Skip to content
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

Run postgres fix #24

Open
wants to merge 169 commits into
base: yy-beat-itest-optimize
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
169 commits
Select commit Hold shift + click to select a range
ce23842
sweep: add new state `TxFatal` for erroneous sweepings
yyforyongyu Apr 30, 2024
6d17657
sweep: add new error `ErrZeroFeeRateDelta`
yyforyongyu Oct 25, 2024
4589da2
sweep: add new interface method `Immediate`
yyforyongyu Oct 25, 2024
5df0954
sweep: handle inputs locally instead of relying on the tx
yyforyongyu Oct 25, 2024
5a97cd5
sweep: add `handleInitialBroadcast` to handle initial broadcast
yyforyongyu Oct 25, 2024
f6189a0
sweep: remove redundant error from `Broadcast`
yyforyongyu Apr 30, 2024
a095a45
sweep: add method `handleBumpEventError` and fix `markInputFailed`
yyforyongyu Apr 30, 2024
a3ffec4
sweep: add method `isMature` on `SweeperInput`
yyforyongyu Apr 30, 2024
d3d13cf
sweep: make sure defaultDeadline is derived from the mature height
yyforyongyu Apr 30, 2024
d2a7200
sweep: remove redundant loopvar assign
yyforyongyu Oct 25, 2024
48eb1f0
sweep: break `initialBroadcast` into two steps
yyforyongyu Nov 7, 2024
297bf55
sweep: make sure nil tx is handled
yyforyongyu Nov 7, 2024
daf76c6
chainio: introduce `chainio` to handle block synchronization
yyforyongyu Jun 27, 2024
7770ea9
chainio: implement `Blockbeat`
yyforyongyu Jun 27, 2024
a15b7a3
chainio: add helper methods to dispatch beats
yyforyongyu Oct 31, 2024
a53fd29
chainio: add `BlockbeatDispatcher` to dispatch blockbeats
yyforyongyu Jun 27, 2024
20e445a
chainio: add partial implementation of `Consumer` interface
yyforyongyu Oct 17, 2024
f47c16b
multi: implement `Consumer` on subsystems
yyforyongyu Oct 29, 2024
bb890a2
sweep: remove block subscription in `UtxoSweeper` and `TxPublisher`
yyforyongyu Jun 4, 2024
b7d7b7f
sweep: remove redundant notifications during shutdown
yyforyongyu Nov 18, 2024
99a8973
contractcourt: remove `waitForHeight` in resolvers
yyforyongyu Jun 4, 2024
3367977
contractcourt: remove block subscription in chain arbitrator
yyforyongyu Oct 29, 2024
270c437
contractcourt: remove block subscription in channel arbitrator
yyforyongyu Oct 29, 2024
fdf08d0
contractcourt: remove the `immediate` param used in `Resolve`
yyforyongyu Jun 4, 2024
8fcd60a
contractcourt: start channel arbitrator with blockbeat
yyforyongyu Oct 29, 2024
cacb8c2
multi: start consumers with a starting blockbeat
yyforyongyu Oct 29, 2024
1d1955d
lnd: add new method `startLowLevelServices`
yyforyongyu Oct 17, 2024
e16170b
lnd: start `blockbeatDispatcher` and register consumers
yyforyongyu Oct 17, 2024
da9360b
contractcourt: fix linter `funlen`
yyforyongyu Oct 29, 2024
83cef59
multi: improve loggings
yyforyongyu May 22, 2024
078cc1e
chainio: use `errgroup` to limit num of goroutines
yyforyongyu Nov 19, 2024
1930601
chainio: update `fn` to `v2`
yyforyongyu Dec 10, 2024
04720ee
contractcourt: add verbose logging in resolvers
yyforyongyu Jun 20, 2024
26ee4cd
contractcourt: add spend path helpers in timeout/success resolver
yyforyongyu Nov 13, 2024
1eaec8d
contractcourt: add sweep senders in `htlcSuccessResolver`
yyforyongyu Nov 14, 2024
9b5e68e
contractcourt: add resolver handlers in `htlcSuccessResolver`
yyforyongyu Nov 14, 2024
d17bceb
contractcourt: remove redundant return value in `claimCleanUp`
yyforyongyu Nov 14, 2024
74ef1d3
contractcourt: add sweep senders in `htlcTimeoutResolver`
yyforyongyu Nov 14, 2024
f32d76d
contractcourt: add methods to checkpoint states
yyforyongyu Jul 16, 2024
817f6fe
contractcourt: add resolve handlers in `htlcTimeoutResolver`
yyforyongyu Jul 16, 2024
3560799
contractcourt: add `Launch` method to anchor/breach resolver
yyforyongyu Jun 24, 2024
3472a10
contractcourt: add `Launch` method to commit resolver
yyforyongyu Jun 20, 2024
53376af
contractcourt: add `Launch` method to htlc success resolver
yyforyongyu Jul 15, 2024
1681573
contractcourt: add `Launch` method to htlc timeout resolver
yyforyongyu Jul 16, 2024
909e926
invoices: exit early when the subscriber chan is nil
yyforyongyu Nov 17, 2024
dcbf867
contractcourt: add `Launch` method to incoming contest resolver
yyforyongyu Nov 17, 2024
d47b33b
contractcourt: add `Launch` method to outgoing contest resolver
yyforyongyu Jun 20, 2024
a2fed61
contractcourt: fix concurrent access to `resolved`
yyforyongyu Jul 10, 2024
b703354
contractcourt: fix concurrent access to `launched`
yyforyongyu Jul 11, 2024
833a454
contractcourt: break `launchResolvers` into two steps
yyforyongyu Jun 25, 2024
8bb9dd4
contractcourt: offer outgoing htlc one block earlier before its expiry
yyforyongyu Nov 25, 2024
bca3357
contractcourt: implement `Consumer` on `chainWatcher`
yyforyongyu Jun 20, 2024
0d59ee8
contractcourt: register spend notification during init
yyforyongyu Nov 16, 2024
d2eaaaa
contractcourt: add method `handleCommitSpend`
yyforyongyu Nov 16, 2024
b239b06
contractcourt: handle blockbeat in `chainWatcher`
yyforyongyu Nov 16, 2024
f16f9bd
contractcourt: notify blockbeat for `chainWatcher`
yyforyongyu Nov 16, 2024
91fd5cd
contractcourt: use close height instead of best height
yyforyongyu Dec 3, 2024
5fbaccd
multi: add new method `ChainArbitrator.RedispatchBlockbeat`
yyforyongyu Nov 13, 2024
2ea3758
contractcourt: add close event handlers in `ChannelArbitrator`
yyforyongyu Nov 16, 2024
b85afc2
contractcourt: process channel close event on new beat
yyforyongyu Nov 13, 2024
837b397
contractcourt: register conf notification once and cancel when confirmed
yyforyongyu Nov 22, 2024
7edace4
chainntnfs: skip dispatched conf details
yyforyongyu Nov 25, 2024
0e44673
docs: add release notes for `blockbeat` series
yyforyongyu Nov 25, 2024
a8fc6fc
multi: optimize loggings around changes from `blockbeat`
yyforyongyu Oct 17, 2024
d6d3e20
lntest+itest: fix `testSweepCPFPAnchorOutgoingTimeout`
yyforyongyu Oct 24, 2024
8ee7882
itest: fix `testSweepCPFPAnchorIncomingTimeout`
yyforyongyu Oct 24, 2024
47fbb51
itest: fix `testSweepHTLCs`
yyforyongyu Oct 24, 2024
eda98dd
itest: fix `testSweepCommitOutputAndAnchor`
yyforyongyu Oct 24, 2024
55d2e8f
itest: fix `testBumpForceCloseFee`
yyforyongyu Oct 17, 2024
b6c4270
itest: fix `testPaymentSucceededHTLCRemoteSwept`
yyforyongyu Oct 24, 2024
123a1a9
lntest+itest: start flattening the multi-hop tests
yyforyongyu Oct 17, 2024
7eecb71
itest: simplify and flatten `testMultiHopReceiverChainClaim`
yyforyongyu Oct 18, 2024
87f6913
lntest+itest: flatten `testMultiHopLocalForceCloseOnChainHtlcTimeout`
yyforyongyu Oct 18, 2024
2730a44
lntest+itest: flatten `testMultiHopRemoteForceCloseOnChainHtlcTimeout`
yyforyongyu Oct 19, 2024
23d4df6
itest: flatten `testMultiHopHtlcLocalChainClaim`
yyforyongyu Oct 21, 2024
140c1c6
itest: flatten `testMultiHopHtlcRemoteChainClaim`
yyforyongyu Oct 22, 2024
43dae14
itest: flatten `testMultiHopHtlcAggregation`
yyforyongyu Oct 23, 2024
131e96b
itest: flatten `testHtlcTimeoutResolverExtractPreimageLocal`
yyforyongyu Oct 23, 2024
b4e66a1
itest: flatten `testHtlcTimeoutResolverExtractPreimageRemote`
yyforyongyu Oct 23, 2024
53e1939
itest: rename file to reflect the tests
yyforyongyu Oct 23, 2024
0f1a269
itest: remove unnecessary force close
yyforyongyu Oct 23, 2024
799716f
itest: remove redundant block mining in `testFailingChannel`
yyforyongyu Oct 24, 2024
6d788c2
itest: remove redunant block mining in `testChannelFundingWithUnstabl…
yyforyongyu Oct 24, 2024
e891c4c
itest: remove redudant block in `testPsbtChanFundingWithUnstableUtxos`
yyforyongyu Oct 24, 2024
6fb1a05
itest: remove redundant blocks in channel backup tests
yyforyongyu Oct 24, 2024
4cd797d
itest+lntest: fix channel force close test
yyforyongyu Jun 29, 2024
b05d46a
itest: flatten and fix `testWatchtower`
yyforyongyu Oct 25, 2024
8dddc98
itest: remove redundant block in multiple tests
yyforyongyu Oct 25, 2024
3ee067d
itest: assert payment status after sending
yyforyongyu Oct 24, 2024
931df1e
lntest+itest: remove the usage of `ht.AssertActiveHtlcs`
yyforyongyu Nov 5, 2024
d29a5cf
htlcswitch: handle nil circuit properly when settling
yyforyongyu Nov 10, 2024
54d6577
routing: fix nil pointer dereference in `exitWithErr`
yyforyongyu Nov 7, 2024
93212a8
lnwallet: add debug logs
yyforyongyu Nov 5, 2024
a55a2f1
itest: print num of blocks for debugging
yyforyongyu Oct 25, 2024
cc1e14c
itest: shuffle test cases to even out blocks mined in tranches
yyforyongyu Oct 24, 2024
aafa8c7
workflows: pass action ID as the shuffle seed
yyforyongyu Nov 7, 2024
44fdb2a
itest: remove direct reference to stanby nodes
yyforyongyu Oct 26, 2024
520ea5d
itest: remove the use of standby nodes
yyforyongyu Nov 20, 2024
67bd3c8
itest: remove unused method `setupFourHopNetwork`
yyforyongyu Nov 20, 2024
f62b824
itest+lntest: remove standby nodes
yyforyongyu Nov 20, 2024
1ac9450
itest: remove unnecessary channel close and node shutdown
yyforyongyu Oct 29, 2024
84da119
lntest: make sure node is properly shut down
yyforyongyu Nov 2, 2024
5caa7fd
lntest: add human-readble names and check num of nodes
yyforyongyu Nov 20, 2024
de9f622
itest: fix `testOpenChannelUpdateFeePolicy`
yyforyongyu Oct 29, 2024
fea9dc0
itest: fix flake in `testSendDirectPayment`
yyforyongyu Nov 20, 2024
3d8973d
itest: fix spawning temp miner
yyforyongyu Oct 29, 2024
99c2668
itest: fix flake for neutrino backend
yyforyongyu Oct 30, 2024
c2ee4e1
itest: flatten PSBT funding test cases
yyforyongyu Oct 30, 2024
cc04db8
itest: fix and document flake in sweeping tests
yyforyongyu Oct 30, 2024
2a68726
itest: remove loop in `wsTestCaseBiDirectionalSubscription`
yyforyongyu Oct 30, 2024
12ae779
itest: fix flake in `testRevokedCloseRetributionZeroValueRemoteOutput`
yyforyongyu Nov 2, 2024
355e030
itest: fix flake in `testSwitchOfflineDelivery`
yyforyongyu Nov 3, 2024
d9f1d0a
itest+routing: fix flake in `runFeeEstimationTestCase`
yyforyongyu Nov 3, 2024
5609d8a
itest: use `ht.CreateSimpleNetwork` whenever applicable
yyforyongyu Nov 3, 2024
ec98025
itest: put mpp tests in one file
yyforyongyu Nov 4, 2024
5cd51b7
lntest+itest: remove `AssertNumActiveEdges`
yyforyongyu Nov 8, 2024
f9906bd
itest: fix flake in runPsbtChanFundingWithNodes
yyforyongyu Nov 10, 2024
a485139
itest: fix flake in `testPrivateUpdateAlias`
yyforyongyu Nov 16, 2024
7476a50
itest: fix flake in `update_pending_open_channels`
yyforyongyu Nov 16, 2024
d796fe3
lntest: increase `rpcmaxwebsockets` for `btcd`
yyforyongyu Nov 20, 2024
990b53f
itest: document details about MPP-related tests
yyforyongyu Nov 21, 2024
e2aa08c
itest+lntest: fix flake in MPP-related tests
yyforyongyu Nov 21, 2024
335c3d4
lntest: fix flakeness in `openChannelsForNodes`
yyforyongyu Nov 22, 2024
9bad9c4
itest: document a rare flake found in `macOS`
yyforyongyu Dec 4, 2024
22c4023
itest: document a flake found in `SendToRoute`
yyforyongyu Dec 4, 2024
9716283
itest: optimize blocks mined in `testGarbageCollectLinkNodes`
yyforyongyu Nov 8, 2024
de5c2f0
itest: break remote signer into independent cases
yyforyongyu Nov 8, 2024
1c71d61
itest: break down channel restore commit types cases
yyforyongyu Nov 8, 2024
6a3d89d
itest: break down utxo selection funding tests
yyforyongyu Nov 8, 2024
43c4309
itest: break all multihop test cases
yyforyongyu Nov 8, 2024
8d76c07
itest: break down scid alias channel update tests
yyforyongyu Nov 8, 2024
6c66c16
itest: break down open channel fee policy
yyforyongyu Nov 8, 2024
8ae7754
itest: break down payment failed tests
yyforyongyu Nov 8, 2024
38a0b90
itest: break down channel backup restore tests
yyforyongyu Nov 8, 2024
2a041b5
itest: break down wallet import account tests
yyforyongyu Nov 8, 2024
cef8abc
itest: break down basic funding flow tests
yyforyongyu Nov 9, 2024
5dfb06d
itest: break down single hop send to route
yyforyongyu Nov 9, 2024
43d308f
itest: break down taproot tests
yyforyongyu Nov 9, 2024
c5bf29f
itest: break down channel fundmax tests
yyforyongyu Nov 9, 2024
cae744e
itest: breakdown `testSendDirectPayment`
yyforyongyu Dec 5, 2024
0535dec
itest: further reduce block mined in tests
yyforyongyu Nov 9, 2024
fdd0025
itest: track and skip flaky tests for windows
yyforyongyu Nov 7, 2024
c8a75fa
lntest: increase node start timeout and payment benchmark timeout
yyforyongyu Nov 9, 2024
d7ef281
lntest: make sure policies are populated in `AssertChannelInGraph`
yyforyongyu Nov 21, 2024
981353b
workflows: use `btcd` for macOS
yyforyongyu Nov 9, 2024
7ffff68
itest+lntest: add new method `FundNumCoins`
yyforyongyu Nov 25, 2024
0b3d049
lntest: limit the num of blocks mined in each test
yyforyongyu Nov 25, 2024
4f12bb2
docs: update release notes
yyforyongyu Nov 26, 2024
9cb87f9
itest: add a prefix before appending a subtest case
yyforyongyu Dec 3, 2024
1281458
itest: even out num of tests per tranche
yyforyongyu Dec 4, 2024
25f3de7
lntest: increase port timeout
yyforyongyu Dec 4, 2024
99e98f2
lntest: add timeouts for windows
yyforyongyu Dec 4, 2024
84825d9
lntest: properly handle shutdown error
yyforyongyu Dec 5, 2024
0aa44c5
workflows: increase num of tranches to 16
yyforyongyu Dec 5, 2024
515ef49
lntest: make sure chain backend is synced to miner
yyforyongyu Dec 7, 2024
f0f19de
itest: document and fix wallet UTXO flake
yyforyongyu Dec 7, 2024
89c027a
itest: fix flake in `testCoopCloseWithExternalDeliveryImpl`
yyforyongyu Dec 10, 2024
028bc8b
lntest: use trace log for `DISC`
yyforyongyu Dec 7, 2024
137c83e
go.mod: update btcwallet to latest to eliminate waddrmgr deadlock
aakselrod Dec 9, 2024
e977065
go.mod: use local kvdb to reapply removal of global postgres lock
aakselrod Oct 30, 2024
6233edf
Reapply "kvdb/postgres: remove global application level lock"
aakselrod Oct 30, 2024
3077a3a
itest: fix flake in multi-hop payments
aakselrod Nov 18, 2024
6bdc162
batch: handle serialization errors correctly
aakselrod Nov 2, 2024
0218093
graph/db: handle previously-unhandled errors
aakselrod Nov 5, 2024
6049fb5
sqldb: improve serialization error handling
aakselrod Nov 6, 2024
5ccc96a
Makefile: tune params for db-instance for postgres itests
aakselrod Nov 6, 2024
538cb42
Makefile: log to file instead of console
aakselrod Nov 15, 2024
6a2b820
github workflow: save postgres log to zip file
aakselrod Nov 15, 2024
d6aa2b6
docs: update release-notes for 0.19.0
aakselrod Nov 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 80 additions & 24 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,14 @@ defaults:
env:
BITCOIN_VERSION: "28"

TRANCHES: 8
# TRANCHES defines the number of tranches used in the itests.
TRANCHES: 16

# SMALL_TRANCHES defines the number of tranches used in the less stable itest
# builds
#
# TODO(yy): remove this value and use TRANCHES.
SMALL_TRANCHES: 8

# If you change this please also update GO_VERSION in Makefile (then run
# `make lint` to see where else it needs to be updated as well).
Expand Down Expand Up @@ -229,10 +236,10 @@ jobs:


########################
# run ubuntu integration tests
# run integration tests with TRANCHES
########################
ubuntu-integration-test:
name: run ubuntu itests
basic-integration-test:
name: basic itests
runs-on: ubuntu-latest
if: '!contains(github.event.pull_request.labels.*.name, ''no-itest'')'
strategy:
Expand All @@ -246,20 +253,75 @@ jobs:
args: backend=bitcoind cover=1
- name: bitcoind-notxindex
args: backend="bitcoind notxindex"
- name: neutrino
args: backend=neutrino cover=1
steps:
- name: git checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: fetch and rebase on ${{ github.base_ref }}
if: github.event_name == 'pull_request'
uses: ./.github/actions/rebase

- name: setup go ${{ env.GO_VERSION }}
uses: ./.github/actions/setup-go
with:
go-version: '${{ env.GO_VERSION }}'
key-prefix: integration-test

- name: install bitcoind
run: ./scripts/install_bitcoind.sh $BITCOIN_VERSION

- name: run ${{ matrix.name }}
run: make itest-parallel tranches=${{ env.TRANCHES }} ${{ matrix.args }} shuffleseed=${{ github.run_id }}${{ strategy.job-index }}

- name: Send coverage
if: ${{ contains(matrix.args, 'cover=1') }}
uses: shogo82148/actions-goveralls@v1
with:
path-to-profile: coverage.txt
flag-name: 'itest-${{ matrix.name }}'
parallel: true

- name: Zip log files on failure
if: ${{ failure() }}
timeout-minutes: 5 # timeout after 5 minute
run: 7z a logs-itest-${{ matrix.name }}.zip itest/**/*.log

- name: Upload log files on failure
uses: actions/upload-artifact@v3
if: ${{ failure() }}
with:
name: logs-itest-${{ matrix.name }}
path: logs-itest-${{ matrix.name }}.zip
retention-days: 5

########################
# run integration tests with SMALL_TRANCHES
########################
integration-test:
name: itests
runs-on: ubuntu-latest
if: '!contains(github.event.pull_request.labels.*.name, ''no-itest'')'
strategy:
# Allow other tests in the matrix to continue if one fails.
fail-fast: false
matrix:
include:
- name: bitcoind-rpcpolling
args: backend="bitcoind rpcpolling" cover=1
args: backend="bitcoind rpcpolling"
- name: bitcoind-etcd
args: backend=bitcoind dbbackend=etcd
- name: bitcoind-postgres
args: backend=bitcoind dbbackend=postgres
- name: bitcoind-sqlite
args: backend=bitcoind dbbackend=sqlite
- name: bitcoind-postgres-nativesql
args: backend=bitcoind dbbackend=postgres nativesql=true
- name: bitcoind-sqlite-nativesql
args: backend=bitcoind dbbackend=sqlite nativesql=true
- name: neutrino
args: backend=neutrino cover=1
- name: bitcoind-postgres
args: backend=bitcoind dbbackend=postgres
- name: bitcoind-postgres-nativesql
args: backend=bitcoind dbbackend=postgres nativesql=true
steps:
- name: git checkout
uses: actions/checkout@v3
Expand All @@ -280,7 +342,7 @@ jobs:
run: ./scripts/install_bitcoind.sh $BITCOIN_VERSION

- name: run ${{ matrix.name }}
run: make itest-parallel tranches=${{ env.TRANCHES }} ${{ matrix.args }}
run: make itest-parallel tranches=${{ env.SMALL_TRANCHES }} ${{ matrix.args }} shuffleseed=${{ github.run_id }}${{ strategy.job-index }}

- name: Send coverage
if: ${{ contains(matrix.args, 'cover=1') }}
Expand All @@ -293,7 +355,7 @@ jobs:
- name: Zip log files on failure
if: ${{ failure() }}
timeout-minutes: 5 # timeout after 5 minute
run: 7z a logs-itest-${{ matrix.name }}.zip itest/**/*.log
run: 7z a logs-itest-${{ matrix.name }}.zip itest/**/*.log itest/postgres.log

- name: Upload log files on failure
uses: actions/upload-artifact@v3
Expand All @@ -308,7 +370,7 @@ jobs:
# run windows integration test
########################
windows-integration-test:
name: run windows itest
name: windows itest
runs-on: windows-latest
if: '!contains(github.event.pull_request.labels.*.name, ''no-itest'')'
steps:
Expand All @@ -328,7 +390,7 @@ jobs:
key-prefix: integration-test

- name: run itest
run: make itest-parallel tranches=${{ env.TRANCHES }} windows=1
run: make itest-parallel tranches=${{ env.SMALL_TRANCHES }} windows=1 shuffleseed=${{ github.run_id }}

- name: kill any remaining lnd processes
if: ${{ failure() }}
Expand All @@ -352,7 +414,7 @@ jobs:
# run macOS integration test
########################
macos-integration-test:
name: run macOS itest
name: macOS itest
runs-on: macos-14
if: '!contains(github.event.pull_request.labels.*.name, ''no-itest'')'
steps:
Expand All @@ -371,14 +433,8 @@ jobs:
go-version: '${{ env.GO_VERSION }}'
key-prefix: integration-test

- name: install bitcoind
run: |
wget https://bitcoincore.org/bin/bitcoin-core-${BITCOIN_VERSION}.0/bitcoin-${BITCOIN_VERSION}.0-arm64-apple-darwin.tar.gz
tar zxvf bitcoin-${BITCOIN_VERSION}.0-arm64-apple-darwin.tar.gz
mv bitcoin-${BITCOIN_VERSION}.0 /tmp/bitcoin

- name: run itest
run: PATH=$PATH:/tmp/bitcoin/bin make itest-parallel tranches=${{ env.TRANCHES }} backend=bitcoind
run: make itest-parallel tranches=${{ env.SMALL_TRANCHES }} shuffleseed=${{ github.run_id }}

- name: Zip log files on failure
if: ${{ failure() }}
Expand Down Expand Up @@ -431,7 +487,7 @@ jobs:
# Notify about the completion of all coverage collecting jobs.
finish:
if: ${{ always() }}
needs: [unit-test, ubuntu-integration-test]
needs: [unit-test, basic-integration-test]
runs-on: ubuntu-latest
steps:
- uses: shogo82148/actions-goveralls@v1
Expand Down
32 changes: 22 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -195,20 +195,32 @@ ifeq ($(dbbackend),postgres)
docker rm lnd-postgres --force || echo "Starting new postgres container"

# Start a fresh postgres instance. Allow a maximum of 500 connections so
# that multiple lnd instances with a maximum number of connections of 50
# each can run concurrently.
docker run --name lnd-postgres -e POSTGRES_PASSWORD=postgres -p 6432:5432 -d postgres:13-alpine -N 500
docker logs -f lnd-postgres &
# that multiple lnd instances with a maximum number of connections of 20
# each can run concurrently. Note that many of the settings here are
# specifically for integration testing and are not fit for running
# production nodes. The increase in max connections ensures that there
# are enough entries allocated for the RWConflictPool to allow multiple
# conflicting transactions to track serialization conflicts. The
# increase in predicate locks and locks per transaction is to allow the
# queries to lock individual rows instead of entire tables, helping
# reduce serialization conflicts. Disabling sequential scan for small
# tables also helps prevent serialization conflicts by ensuring lookups
# lock only relevant rows in the index rather than the entire table.
docker run --name lnd-postgres -e POSTGRES_PASSWORD=postgres -p 6432:5432 -d postgres:13-alpine -N 1500 -c max_pred_locks_per_transaction=1024 -c max_locks_per_transaction=128 -c enable_seqscan=off
docker logs -f lnd-postgres >itest/postgres.log 2>&1 &

# Wait for the instance to be started.
sleep $(POSTGRES_START_DELAY)
endif

clean-itest-logs:
rm -rf itest/*.log itest/.logs-*

#? itest-only: Only run integration tests without re-building binaries
itest-only: db-instance
itest-only: clean-itest-logs db-instance
@$(call print, "Running integration tests with ${backend} backend.")
rm -rf itest/*.log itest/.logs-*; date
EXEC_SUFFIX=$(EXEC_SUFFIX) scripts/itest_part.sh 0 1 $(TEST_FLAGS) $(ITEST_FLAGS) -test.v
date
EXEC_SUFFIX=$(EXEC_SUFFIX) scripts/itest_part.sh 0 1 $(SHUFFLE_SEED) $(TEST_FLAGS) $(ITEST_FLAGS) -test.v
$(COLLECT_ITEST_COVERAGE)

#? itest: Build and run integration tests
Expand All @@ -218,10 +230,10 @@ itest: build-itest itest-only
itest-race: build-itest-race itest-only

#? itest-parallel: Build and run integration tests in parallel mode, running up to ITEST_PARALLELISM test tranches in parallel (default 4)
itest-parallel: build-itest db-instance
itest-parallel: clean-itest-logs build-itest db-instance
@$(call print, "Running tests")
rm -rf itest/*.log itest/.logs-*; date
EXEC_SUFFIX=$(EXEC_SUFFIX) scripts/itest_parallel.sh $(ITEST_PARALLELISM) $(NUM_ITEST_TRANCHES) $(TEST_FLAGS) $(ITEST_FLAGS)
date
EXEC_SUFFIX=$(EXEC_SUFFIX) scripts/itest_parallel.sh $(ITEST_PARALLELISM) $(NUM_ITEST_TRANCHES) $(SHUFFLE_SEED) $(TEST_FLAGS) $(ITEST_FLAGS)
$(COLLECT_ITEST_COVERAGE)

#? itest-clean: Kill all running itest processes
Expand Down
17 changes: 15 additions & 2 deletions batch/batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"sync"

"github.com/lightningnetwork/lnd/kvdb"
"github.com/lightningnetwork/lnd/sqldb"
)

// errSolo is a sentinel error indicating that the requester should re-run the
Expand Down Expand Up @@ -55,8 +56,20 @@ func (b *batch) run() {
for i, req := range b.reqs {
err := req.Update(tx)
if err != nil {
failIdx = i
return err
// If we get a serialization error, we
// want the underlying SQL retry
// mechanism to retry the entire batch.
// Otherwise, we can succeed in an
// sqldb retry and still re-execute the
// failing request individually.
dbErr := sqldb.MapSQLError(err)
if !sqldb.IsSerializationError(dbErr) {
failIdx = i

return err
}

return dbErr
}
}
return nil
Expand Down
74 changes: 74 additions & 0 deletions batch/batch_test.go
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")
}
Loading
Loading