lightningnetwork / lnd

Lightning Network Daemon ⚡️
MIT License
7.63k stars 2.07k forks source link

[bug]: observed data race in router unit test #8964

Closed hieblmi closed 1 month ago

hieblmi commented 1 month ago

Background

Observed the following race condition in make btcd unit-race

==================
WARNING: DATA RACE
Write at 0x00c000371910 by goroutine 4238:
  github.com/lightningnetwork/lnd/routing.TestNewRouteRequest.func1()
      /home/runner/work/lnd/lnd/routing/router_test.go:2239 +0x155
  testing.tRunner()
      /opt/hostedtoolcache/go/1.22.5/x64/src/testing/testing.go:1689 +0x21e
  testing.(*T).Run.gowrap1()
      /opt/hostedtoolcache/go/1.22.5/x64/src/testing/testing.go:1742 +0x44

Previous write at 0x00c000371910 by goroutine 4240:
  github.com/lightningnetwork/lnd/routing.TestNewRouteRequest.func1()
      /home/runner/work/lnd/lnd/routing/router_test.go:2239 +0x155
  testing.tRunner()
      /opt/hostedtoolcache/go/1.22.5/x64/src/testing/testing.go:1689 +0x21e
  testing.(*T).Run.gowrap1()
      /opt/hostedtoolcache/go/1.22.5/x64/src/testing/testing.go:1742 +0x44

Goroutine 4238 (running) created at:
  testing.(*T).Run()
      /opt/hostedtoolcache/go/1.22.5/x64/src/testing/testing.go:1742 +0x825
  github.com/lightningnetwork/lnd/routing.TestNewRouteRequest()
      /home/runner/work/lnd/lnd/routing/router_test.go:2[231](https://github.com/lightningnetwork/lnd/actions/runs/10194791831/job/28202115109?pr=8836#step:8:232) +0x1230
  testing.tRunner()
      /opt/hostedtoolcache/go/1.22.5/x64/src/testing/testing.go:1689 +0x21e
  testing.(*T).Run.gowrap1()
      /opt/hostedtoolcache/go/1.22.5/x64/src/testing/testing.go:1742 +0x44

Goroutine 4240 (finished) created at:
  testing.(*T).Run()
      /opt/hostedtoolcache/go/1.22.5/x64/src/testing/testing.go:1742 +0x825
  github.com/lightningnetwork/lnd/routing.TestNewRouteRequest()
      /home/runner/work/lnd/lnd/routing/router_test.go:2231 +0x1230
  testing.tRunner()
      /opt/hostedtoolcache/go/1.22.5/x64/src/testing/testing.go:1689 +0x21e
  testing.(*T).Run.gowrap1()
      /opt/hostedtoolcache/go/1.22.5/x64/src/testing/testing.go:1742 +0x44
==================

Your environment

yyforyongyu commented 1 month ago

looks like there's another race from this build when merging #8764,

--- FAIL: TestMigrations (0.00s)
    --- FAIL: TestMigrations/TestInvoiceExpiryMigration_Postgres (15.04s)
        postgres_fixture.go:70: 
                Error Trace:    /home/runner/work/lnd/lnd/sqldb/postgres_fixture.go:70
                                            /home/runner/work/lnd/lnd/sqldb/migrations_test.go:30
                                            /home/runner/work/lnd/lnd/sqldb/migrations_test.go:75
                                            /home/runner/work/lnd/lnd/sqldb/migrations_test.go:60
                Error:          Received unexpected error:
                                API error (500): Get "https://registry-1.docker.io/v2/": net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
                Test:           TestMigrations/TestInvoiceExpiryMigration_Postgres
                Messages:       Could not start resource
FAIL
FAIL    github.com/lightningnetwork/lnd/sqldb   15.051s
FAIL
ok      github.com/lightningnetwork/lnd/zpay32  1.995s
--- FAIL: TestInvoiceRegistry (15.01s)
    postgres_fixture.go:70: 
            Error Trace:    /home/runner/work/lnd/lnd/sqldb/postgres_fixture.go:70
                                        /home/runner/work/lnd/lnd/invoices/invoiceregistry_test.go:121
            Error:          Received unexpected error:
                            API error (500): Get "https://registry-1.docker.io/v2/": net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
            Test:           TestInvoiceRegistry
            Messages:       Could not start resource
--- FAIL: TestInvoices (15.01s)
    postgres_fixture.go:70: 
            Error Trace:    /home/runner/work/lnd/lnd/sqldb/postgres_fixture.go:70
                                        /home/runner/work/lnd/lnd/invoices/invoices_test.go:227
            Error:          Received unexpected error:
                            API error (500): Get "https://registry-1.docker.io/v2/": net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
            Test:           TestInvoices
            Messages:       Could not start resource
FAIL
FAIL    github.com/lightningnetwork/lnd/invoices    30.208s
FAIL
Roasbeef commented 1 month ago

@yyforyongyu is that a race? That just looks like the docker API timing out.

ellemouton commented 1 month ago

Hey yall - fixing this in the route blinding follow up PR 👍 (well, at least the TestNewRouteRequest part. i think the TestInvoiceExpiryMigration_Postgres is separate)