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

ingest/ledgerbackend: getLogLineWriter() leaks goroutines and pipes #5342

Closed
2opremio opened this issue Jun 13, 2024 · 5 comments
Closed

ingest/ledgerbackend: getLogLineWriter() leaks goroutines and pipes #5342

2opremio opened this issue Jun 13, 2024 · 5 comments

Comments

@2opremio
Copy link
Contributor

2opremio commented Jun 13, 2024

getLogLineWriter() creates a pipe and a goroutine, but the goroutine sometimes doesn't exit (and the pipe is never released).

Every time captive core is restarted this causes a leak.

The easiest fix is probably returning a CloseWriter and making sure that the writer is closed (releasing the pipe and the goroutine).

@2opremio
Copy link
Contributor Author

2opremio commented Jun 13, 2024

Discovered while investigating failing tests at stellar/stellar-rpc#207

@2opremio
Copy link
Contributor Author

2opremio commented Jun 13, 2024

It turns out the goroutines are closed in many places but something must be amiss, since they are still left behind in some cases. All the (*pipe).read goroutines in this dump are from Closed() captive core backends (from different soroban-rpc tests):

Screenshot 2024-06-13 at 17 30 56

@2opremio
Copy link
Contributor Author

I think stellarCoreRunner.handleExit() may not be closing the pipes in some cases

@2opremio
Copy link
Contributor Author

Here's another dump:

Screenshot 2024-06-13 at 18 28 57

@tamirms
Copy link
Contributor

tamirms commented Jun 14, 2024

It looks like there are a few createCmd calls where we do not close the log line writers:

cmd, err := r.createCmd("new-db")

if from > 2 {
cmd, err = r.createCmd("catchup", fmt.Sprintf("%d/0", from-1))
} else {
cmd, err = r.createCmd("catchup", "2/0")
}

cmd, err := r.createCmd("new-db")

@2opremio 2opremio mentioned this issue Jun 18, 2024
2opremio added a commit to 2opremio/soroban-rpc that referenced this issue Jun 18, 2024
Add a workaround for stellar/go#5342 ,
which is causing a race in integration tests.
2opremio added a commit to 2opremio/soroban-rpc that referenced this issue Jun 18, 2024
Add a workaround for stellar/go#5342 ,
which is causing a race in integration tests.
2opremio added a commit to 2opremio/soroban-rpc that referenced this issue Jun 18, 2024
Add a workaround for stellar/go#5342 ,
which is causing a race in integration tests.
@tamirms tamirms added this to the platform sprint 48 milestone Jun 26, 2024
@tamirms tamirms moved this from Backlog to In Progress in Platform Scrum Jun 26, 2024
@tamirms tamirms moved this from In Progress to Needs Review in Platform Scrum Jun 26, 2024
@tamirms tamirms closed this as completed Jun 28, 2024
@github-project-automation github-project-automation bot moved this from Needs Review to Done in Platform Scrum Jun 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

No branches or pull requests

3 participants
@tamirms @2opremio and others