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

Do not rely on GC to close Aerospike client connections #40

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 12 additions & 0 deletions pkg/aerospike/checks.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,3 +269,15 @@ func DurabilityCheck(p topology.ProbeableEndpoint) error {
durabilityCorruptedItems.WithLabelValues(e.Namespace, e.ClusterName, e.GetName()).Set(total_corrupted_items)
return nil
}

func Teardown(p topology.ProbeableEndpoint) error {
e, ok := p.(*AerospikeEndpoint)
if !ok {
return fmt.Errorf("error: given endpoint is not an aerospike endpoint")
}

// Do not rely on GC - we've already seen resource leaks happen
e.Client.Close()

return nil
}
4 changes: 2 additions & 2 deletions probes/aerospike/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func main() {
Name: "latency_check",
PrepareFn: scheduler.Noop,
CheckFn: aerospike.LatencyCheck,
TeardownFn: scheduler.Noop,
TeardownFn: aerospike.Teardown,
Interval: config.AerospikeChecksConfigs.LatencyCheckConfig.Interval,
})
}
Expand All @@ -87,7 +87,7 @@ func main() {
Name: "durability_check",
PrepareFn: aerospike.DurabilityPrepare,
CheckFn: aerospike.DurabilityCheck,
TeardownFn: scheduler.Noop,
TeardownFn: aerospike.Teardown, // It is okay to call aerospike.Client.Close multiple times
Interval: config.AerospikeChecksConfigs.DurabilityCheckConfig.Interval,
})
}
Expand Down
Loading