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

New Go SDK does not support the use of Goroutines #1254

Closed
OwenJacob opened this issue May 8, 2019 · 1 comment
Closed

New Go SDK does not support the use of Goroutines #1254

OwenJacob opened this issue May 8, 2019 · 1 comment
Labels
horizonclient tag for new horizon client located in clients/horizonclient

Comments

@OwenJacob
Copy link
Contributor

I'm using Goroutines because I want to deal with many accounts as quickly as possible as part of a test suite. When I use the new SDK to call to Horizon (so far I have only tried to use SubmitTransactionXDR or AccountDetails concurrently) The code panics.

A small piece of example code that attempts to get multiple account details concurrently:

func Concurrentaccount() {
	var wg sync.WaitGroup

	for i := 0; i < 1000; i++ {
		wg.Add(1)
		go func(i int) {
			defer wg.Done()
			reqsource := horizonclient.AccountRequest{AccountID: testAccs[i].publickey}
			source, _ := c.AccountDetail(reqsource)
			fmt.Println(source)
		}(i)
	}
	wg.Wait()
}

testAccs[i].publickey is an array of structs holding keypairs as strings.

A typical panic message:

goroutine 880 [running]:
runtime.throw(0x1366d04, 0x15)
	/usr/local/go/src/runtime/panic.go:617 +0x72 fp=0xc00078b7f8 sp=0xc00078b7c8 pc=0x102ce42
runtime.mapassign_faststr(0x1300aa0, 0xc0000a97d0, 0xc0000729a8, 0x17, 0x15f88a0)
	/usr/local/go/src/runtime/map_faststr.go:291 +0x3ff fp=0xc00078b860 sp=0xc00078b7f8 pc=0x101428f
github.com/stellar/go/clients/horizonclient.setCurrentServerTime(0xc0000729a8, 0x17, 0xc00336d390, 0x1, 0x1)
	/go/src/github.com/stellar/go/clients/horizonclient/internal.go:118 +0x1ea fp=0xc00078b908 sp=0xc00078b860 pc=0x12bb50a
github.com/stellar/go/clients/horizonclient.decodeResponse(0xc0012fb7a0, 0x12e1ac0, 0xc000724610, 0x0, 0x0)
	/go/src/github.com/stellar/go/clients/horizonclient/internal.go:20 +0x2fa fp=0xc00078b980 sp=0xc00078b908 pc=0x12bb13a
github.com/stellar/go/clients/horizonclient.(*Client).sendRequestURL(0x15f8720, 0xc0000729a0, 0x61, 0x1360d36, 0x3, 0x1332d40, 0xc0006d9980, 0xc000040af8, 0xc00000f4e0)
	/go/src/github.com/stellar/go/clients/horizonclient/client.go:67 +0x396 fp=0xc00078ba48 sp=0xc00078b980 pc=0x12ba4d6
github.com/stellar/go/clients/horizonclient.(*Client).sendRequest(0x15f8720, 0x13d1260, 0xc00000f4e0, 0x1332d40, 0xc0006d9980, 0x0, 0x0)
	/go/src/github.com/stellar/go/clients/horizonclient/client.go:37 +0x216 fp=0xc00078bab0 sp=0xc00078ba48 pc=0x12ba0e6
github.com/stellar/go/clients/horizonclient.(*Client).AccountDetail(0x15f8720, 0xc000168b52, 0x38, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
	/go/src/github.com/stellar/go/clients/horizonclient/client.go:233 +0x108 fp=0xc00078bb28 sp=0xc00078bab0 pc=0x12bacb8
git.sabay.com/payment-network/app.srv.spn-loadtest.sabay.one/accops.Concurrentaccount.func1(0xc000016fe4, 0x30b)
	/go/src/git.sabay.com/payment-network/app.srv.spn-loadtest.sabay.one/accops/helpers.go:126 +0xcd fp=0xc00078bfd0 sp=0xc00078bb28 pc=0x12bca4d
runtime.goexit()
	/usr/local/go/src/runtime/asm_amd64.s:1337 +0x1 fp=0xc00078bfd8 sp=0xc00078bfd0 pc=0x1058501
created by git.sabay.com/payment-network/app.srv.spn-loadtest.sabay.one/accops.Concurrentaccount
	/go/src/git.sabay.com/payment-network/app.srv.spn-loadtest.sabay.one/accops/helpers.go:123 +0x82
exit status 2

In the depreciated Go SDK I was able to submit transactions and request account details concurrently

@ire-and-curses ire-and-curses added the horizonclient tag for new horizon client located in clients/horizonclient label May 8, 2019
@debnil
Copy link
Contributor

debnil commented May 14, 2019

@OwenJacob: #1276 fixed this error for my use case. It's been merged onto the master branch and will be included in the next release (1.2) of horizonclient this week.

@debnil debnil closed this as completed May 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
horizonclient tag for new horizon client located in clients/horizonclient
Projects
None yet
Development

No branches or pull requests

3 participants