exercism/go-test-runner

potential BUG: bank-account exercise, timeout issue

Opened this issue · 4 comments

local go version: go1.20.6 linux/amd64
exercise: Bank Account in Go

I may have found an infrastructure bug.
My tests timed out on the server, but couldn't find where I was messing up even when comparing to community solutions. I requested mentoring, and bernot-dev replied and mentioned that he thinks it's an issue with infrastructure. We both run it and pass tests locally.

Let me know what other information I may provide.

Unsure if this will give you access, Direct mentoring link to my attempt on this exercise, with source copied below.

my code, copied from iteration 5

package account
import (
	"sync"
)
// Define the Account type here.
type Account struct {
	balance int64
	active  bool
	mu      sync.RWMutex
}
func Open(amount int64) *Account {
	if amount < 0 {
		return nil
	}
	return &Account{
		balance: amount,
		active:  true,
		mu:      sync.RWMutex{},
	}
}
// Balance returns the balance of the account
func (a *Account) Balance() (int64, bool) {
	a.mu.RLock()
	defer a.mu.RUnlock()
	b, ok := a.balance, a.active
	// fail early in lieu of returning invalid state on API
	if b > 0 && !ok {
		panic("an inactive account has nonzero balance")
	} else if b < 0 {
		panic("account found with negative balance")
	}
	return b, ok
}
func (a *Account) Deposit(amount int64) (int64, bool) {
	a.mu.Lock()
	defer a.mu.Unlock()
	b, ok := a.balance, a.active
	if !ok || b+amount < 0 {
		return b, false
	}
	b += amount
	a.balance = b
	return b, true
}
func (a *Account) Close() (int64, bool) {
	a.mu.Lock()
	defer a.mu.Unlock()
	b, ok := a.balance, a.active
	if !ok {
		return 0, false
	}
	a.balance, a.active = 0, false
	return b, true
}

Hello. Thanks for opening an issue on Exercism 🙂

At Exercism we use our Community Forum, not GitHub issues, as the primary place for discussion. That allows maintainers and contributors from across Exercism's ecosystem to discuss your problems/ideas/suggestions without them having to subscribe to hundreds of repositories.

This issue will be automatically closed. Please use this link to copy your GitHub Issue into a new topic on the forum, where we look forward to chatting with you!

If you're interested in learning more about this auto-responder, please read this blog post.

Hello. Thanks for opening an issue on Exercism 🙂

At Exercism we use our Community Forum, not GitHub issues, as the primary place for discussion. That allows maintainers and contributors from across Exercism's ecosystem to discuss your problems/ideas/suggestions without them having to subscribe to hundreds of repositories.

This issue will be automatically closed. Please use this link to copy your GitHub Issue into a new topic on the forum, where we look forward to chatting with you!

If you're interested in learning more about this auto-responder, please read this blog post.

@ErikSchierboom For this exercise, we run Go's built-in race detector. This makes the test run a bit slower but until now we didn't get complains about timeouts. Do you have a way to check whether we started to get more timeouts than usual at some point?

Exercises without the race detector seem to work as fast as usual. I can of course remove the flag for the race detector from the exercise config but it's quite a nice feature to show to students if it kicks in.

Do you have a way to check whether we started to get more timeouts than usual at some point?

Not really no, sorry :(