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

goroutine leak in driver package: init() #131

Closed
crobert-1 opened this issue Jan 12, 2024 · 2 comments
Closed

goroutine leak in driver package: init() #131

crobert-1 opened this issue Jan 12, 2024 · 2 comments

Comments

@crobert-1
Copy link

Context
See #130

Bug
Here's the goleak output:

[Goroutine 13 in state chan receive, with github.com/SAP/go-hdb/driver.(*metrics).collect on top of the stack:
github.com/SAP/go-hdb/driver.(*metrics).collect(0xc001a900a0, 0x0?, 0x0?)
        /Users/crobert/go/pkg/mod/github.com/!s!a!p/go-hdb@v1.7.1/driver/metrics.go:192 +0x97
created by github.com/SAP/go-hdb/driver.newMetrics in goroutine 1
        /Users/crobert/go/pkg/mod/github.com/!s!a!p/go-hdb@v1.7.1/driver/metrics.go:146 +0x510

This is caused by running a goroutine from within init. This leak will happen with every direct and indirect import of the driver package.

This is the line of code in init that will eventually start a running goroutine:

stdHdbDriver = &hdbDriver{metrics: newMetrics(nil, statsCfg.TimeUnit, statsCfg.TimeUpperBounds)}

Solution
I'd suggest only starting a goroutine when required by the package's functionality, and include a public way to stop it when execution is done.

@crobert-1 crobert-1 changed the title goleak in driver package: init() goroutine leak in driver package: init() Jan 12, 2024
@stfnmllr
Copy link
Contributor

should be fixed with https://github.com/SAP/go-hdb/releases/tag/v1.7.5

@crobert-1
Copy link
Author

Thanks @stfnmllr!

mx-psi referenced this issue in open-telemetry/opentelemetry-collector-contrib Jan 23, 2024
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [github.com/SAP/go-hdb](https://togithub.com/SAP/go-hdb) | `v1.7.4` ->
`v1.7.6` |
[![age](https://developer.mend.io/api/mc/badges/age/go/github.com%2fSAP%2fgo-hdb/v1.7.6?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/go/github.com%2fSAP%2fgo-hdb/v1.7.6?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/go/github.com%2fSAP%2fgo-hdb/v1.7.4/v1.7.6?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/go/github.com%2fSAP%2fgo-hdb/v1.7.4/v1.7.6?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>SAP/go-hdb (github.com/SAP/go-hdb)</summary>

###
[`v1.7.6`](https://togithub.com/SAP/go-hdb/blob/HEAD/RELEASENOTES.md#v176)

[Compare
Source](https://togithub.com/SAP/go-hdb/compare/v1.7.5...v1.7.6)

-   updated dependencies
-   bulkbench refresh

###
[`v1.7.5`](https://togithub.com/SAP/go-hdb/blob/HEAD/RELEASENOTES.md#v175)

[Compare
Source](https://togithub.com/SAP/go-hdb/compare/v1.7.4...v1.7.5)

-   updated dependencies
-   fixed issue starting go routines during driver initialization
-
[https://github.com/SAP/go-hdb/issues/130](https://togithub.com/SAP/go-hdb/issues/130)
-
[https://github.com/SAP/go-hdb/issues/131](https://togithub.com/SAP/go-hdb/issues/131)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "on tuesday" (UTC), Automerge - At any
time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/open-telemetry/opentelemetry-collector-contrib).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4xMzUuMCIsInVwZGF0ZWRJblZlciI6IjM3LjEzNS4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: opentelemetrybot <107717825+opentelemetrybot@users.noreply.github.com>
cparkins referenced this issue in AmadeusITGroup/opentelemetry-collector-contrib Feb 1, 2024
…try#30712)

[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [github.com/SAP/go-hdb](https://togithub.com/SAP/go-hdb) | `v1.7.4` ->
`v1.7.6` |
[![age](https://developer.mend.io/api/mc/badges/age/go/github.com%2fSAP%2fgo-hdb/v1.7.6?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/go/github.com%2fSAP%2fgo-hdb/v1.7.6?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/go/github.com%2fSAP%2fgo-hdb/v1.7.4/v1.7.6?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/go/github.com%2fSAP%2fgo-hdb/v1.7.4/v1.7.6?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>SAP/go-hdb (github.com/SAP/go-hdb)</summary>

###
[`v1.7.6`](https://togithub.com/SAP/go-hdb/blob/HEAD/RELEASENOTES.md#v176)

[Compare
Source](https://togithub.com/SAP/go-hdb/compare/v1.7.5...v1.7.6)

-   updated dependencies
-   bulkbench refresh

###
[`v1.7.5`](https://togithub.com/SAP/go-hdb/blob/HEAD/RELEASENOTES.md#v175)

[Compare
Source](https://togithub.com/SAP/go-hdb/compare/v1.7.4...v1.7.5)

-   updated dependencies
-   fixed issue starting go routines during driver initialization
-
[https://github.com/SAP/go-hdb/issues/130](https://togithub.com/SAP/go-hdb/issues/130)
-
[https://github.com/SAP/go-hdb/issues/131](https://togithub.com/SAP/go-hdb/issues/131)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "on tuesday" (UTC), Automerge - At any
time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/open-telemetry/opentelemetry-collector-contrib).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4xMzUuMCIsInVwZGF0ZWRJblZlciI6IjM3LjEzNS4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: opentelemetrybot <107717825+opentelemetrybot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants