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: Captive core's LogLineWriter should be closed synchronously #5350

Closed
2opremio opened this issue Jun 16, 2024 · 0 comments · Fixed by #5352
Closed

ingest/ledgerbackend: Captive core's LogLineWriter should be closed synchronously #5350

2opremio opened this issue Jun 16, 2024 · 0 comments · Fixed by #5352
Assignees
Labels

Comments

@2opremio
Copy link
Contributor

2opremio commented Jun 16, 2024

We just close the writer side of the pipe but don't wait for the goroutine to exit:

func (r *stellarCoreRunner) getLogLineWriter() io.Writer {
rd, wr := io.Pipe()
br := bufio.NewReader(rd)
// Strip timestamps from log lines from captive stellar-core. We emit our own.
dateRx := regexp.MustCompile(`^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3} `)
go func() {
levelRx := regexp.MustCompile(`\[(\w+) ([A-Z]+)\] (.*)`)
for {
line, err := br.ReadString('\n')
if err != nil {
break
}

This can cause an extra log line to be written after closing the backend, which causes problems in the new Soroban RPC integration tests. See https://github.com/stellar/soroban-rpc/actions/runs/9538438244/job/26287637351?pr=216#step:10:50

In this particular case, from a dangling goroutine is causing a race condition with Go's testing library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants
@tamirms @2opremio and others