aerospike / aerospike-client-go

Aerospike Client Go
Apache License 2.0
429 stars 199 forks source link

fix: removing source SIGSEGV that leads to crash #379

Closed adumovic closed 2 years ago

adumovic commented 2 years ago

When a server node is removed during a partition scan, for some reason, the tracker instance gets set to null (haven't tracked down where this happens as it seemed the lifetime of the tracker was pretty coupled to its use with the command).

All other locations where cmd.tracker are used are protected by a tracker != nil check but the modified one in this PR.

In the case that it is nil, I made a decision to create an error I can observer and handle from my client code but THAT MAY NOT BE THE BEST OPTION HERE.

The main reason I made it return the PARTITION_UNAVAILABLE error is that, before the crashes, I frequently see it logged.

Here is the bug and a copy of the stack trace:

https://github.com/aerospike/aerospike-client-go/issues/375

`panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0xc845e0]

goroutine 33749 [running]:
github.com/aerospike/aerospike-client-go/v5.(*partitionTracker).partitionDone(...)
    /go/src/myService/vendor/github.com/aerospike/aerospike-client-go/v5/partition_tracker.go:232
github.com/aerospike/aerospike-client-go/v5.(*baseMultiCommand).parseRecordResults(0xc001b44900, {0xc43557, 0xc001b449b8}, 0x16)
    /go/src/myService/vendor/github.com/aerospike/aerospike-client-go/v5/multi_command.go:297 +0x160
github.com/aerospike/aerospike-client-go/v5.(*baseMultiCommand).parseResult(0xc001b44900, {0x133e858, 0xc001b44900}, 0x1b7ca60)
    /go/src/myService/vendor/github.com/aerospike/aerospike-client-go/v5/multi_command.go:174 +0x307
github.com/aerospike/aerospike-client-go/v5.(*queryCommand).parseResult(0xc0013eff40, {0x133e858, 0xc001b44900}, 0x10000)
    /go/src/myService/vendor/github.com/aerospike/aerospike-client-go/v5/query_command.go:45 +0x25
github.com/aerospike/aerospike-client-go/v5.(*baseCommand).executeAt(0xc001b44900, {0x133e858, 0xc001b44900}, 0xc00137c510, 0xbf, {0xc011efa700, 0xc011efa6d0, 0x1b7ca60}, 0x1169661, 0x0)
    /go/src/myService/vendor/github.com/aerospike/aerospike-client-go/v5/command.go:2166 +0xedc
github.com/aerospike/aerospike-client-go/v5.(*baseCommand).execute(0xc86ffa, {0x133e858, 0xc001b44900}, 0x0)
    /go/src/myService/vendor/github.com/aerospike/aerospike-client-go/v5/command.go:1991 +0x8a
github.com/aerospike/aerospike-client-go/v5.(*baseMultiCommand).execute(...)
    /go/src/myService/vendor/github.com/aerospike/aerospike-client-go/v5/multi_command.go:399
github.com/aerospike/aerospike-client-go/v5.(*queryCommand).Execute(0xc001b44900)
    /go/src/myService/vendor/github.com/aerospike/aerospike-client-go/v5/query_command.go:50 +0x2f
github.com/aerospike/aerospike-client-go/v5.(*werrGroup).execute.func1()
    /go/src/myService/vendor/github.com/aerospike/aerospike-client-go/v5/werrgroup.go:62 +0xdb
created by github.com/aerospike/aerospike-client-go/v5.(*werrGroup).execute
    /go/src/myService/vendor/github.com/aerospike/aerospike-client-go/v5/werrgroup.go:55 +0x15a`
khaf commented 2 years ago

Thanks for your PR, released in v5.9.0. I took the liberty to rebase and squash the commits into one.