StationA / tilenol

Scalable, multi-backend geo vector tile server
MIT License
22 stars 6 forks source link

Tilenol crashes with nil pointer exception #39

Closed audreyyku closed 3 years ago

audreyyku commented 3 years ago

Describe the bug Tilenol crashes upon nil exception, however this bug is unpredictably reproducible. The main problem with this bug is the uncertainty of how and when it will occur and that it causes tilenol to stop running entirely.

To Reproduce Line run right prior to error (in tilenol/examples/postgis):

../../target/tilenol run -x -d

When rendering the locally hosted tilenol via a local html file, tilenol works as expected, but at some point in time crashes with nil pointer dereference.

Hypothesized causes:

Stack trace:

...
INFO[0018] [...] "GET http://localhost:3000/list-locations/11/620/758.mvt?q=list_id%20%3D%20%2701EG4NCCHP5PJF4NHE2P4MV7V8%27 HTTP/1.1" from [::1]:58250 - 200 47B in 10.037610166s
panic: runtime error: invalid memory address or nil pointer dereference
    panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x1569646]

goroutine 947 [running]:
github.com/doug-martin/goqu/v9.(*TxDatabase).Trace(0x0, 0x18f5626, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0)
    /.../go/pkg/mod/github.com/doug-martin/goqu/v9@v9.10.0/database.go:493 +0x26
github.com/doug-martin/goqu/v9.(*TxDatabase).Rollback(0x0, 0x9, 0x0)
    /.../go/pkg/mod/github.com/doug-martin/goqu/v9@v9.10.0/database.go:605 +0x56
panic(0x1806040, 0x1e601d0)
    /usr/local/go/src/runtime/panic.go:969 +0x1b9
github.com/doug-martin/goqu/v9.(*TxDatabase).Trace(0x0, 0x18f2154, 0x5, 0xc000554000, 0x6c8, 0x0, 0x0, 0x0)
    /.../go/pkg/mod/github.com/doug-martin/goqu/v9@v9.10.0/database.go:493 +0x26
github.com/doug-martin/goqu/v9.(*TxDatabase).QueryContext(0x0, 0x19d53a0, 0xc0000b4008, 0xc000554000, 0x6c8, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
    /.../go/pkg/mod/github.com/doug-martin/goqu/v9@v9.10.0/database.go:535 +0x85
github.com/doug-martin/goqu/v9.(*TxDatabase).Query(...)
    /.../go/pkg/mod/github.com/doug-martin/goqu/v9@v9.10.0/database.go:530
github.com/stationa/tilenol.(*PostGISSource).runQuery(0xc0001cfa70, 0x19d5360, 0xc00020e600, 0xc000554000, 0x6c8, 0x0, 0x0, 0x0, 0x0, 0x0)
    /.../dev/src/github.com/stationa/tilenol/postgis_source.go:206 +0x21a
github.com/stationa/tilenol.(*PostGISSource).GetFeatures(0xc0001cfa70, 0x19d5360, 0xc00020e600, 0xc00060c060, 0xc00027ff28, 0x4, 0x4)
    /.../dev/src/github.com/stationa/tilenol/postgis_source.go:250 +0x325
github.com/stationa/tilenol.(*Server).getVectorTile.func1(0x0, 0x0)
    /.../dev/src/github.com/stationa/tilenol/server.go:270 +0x223
golang.org/x/sync/errgroup.(*Group).Go.func1(0xc0004f4240, 0xc00041c0a0)
    /.../go/pkg/mod/golang.org/x/sync@v0.0.0-20201020160332-67f06af15bc9/errgroup/errgroup.go:57 +0x59
created by golang.org/x/sync/errgroup.(*Group).Go
    /.../go/pkg/mod/golang.org/x/sync@v0.0.0-20201020160332-67f06af15bc9/errgroup/errgroup.go:54 +0x66

Note: When running the following script to re-run all the requests from the stack trace above (sequentially), there were no errors.

cat tilenol_logs.txt | grep OPTIONS | cut -d" " -f 4 | xargs curl --compressed -v

Expected behavior Tilenol runs without crashing.

Desktop (please complete the following information):

jerluc commented 3 years ago

Just wanted to add that I was also able to by chance reproduce this same issue on my Linux desktop, which mostly throws out the suspicion that this is platform-specific:

That said, it is very tricky to reproduce, but seems to have only recently popped up with the introduction of the PostGIS source, and seems to also correspond with quickly moving around the map. This makes me think that possibly the PostGIS source implementation does not respond well to request cancellations (see #42), which are a common occurrence when panning quickly on the map, and as a result, this can sometimes panic under certain conditions.