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

[bug] when enable tracing support, I find that there are concurrent operations with map #9

Closed
LinkinStars opened this issue Oct 9, 2020 · 4 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@LinkinStars
Copy link

error message

fatal error: concurrent map writes
fatal error: concurrent map writes

goroutine 67 [running]:
runtime.throw(0x14d49a2, 0x15)
        /usr/local/go/src/runtime/panic.go:1116 +0x72 fp=0xc00038b6e0 sp=0xc00038b6b0 pc=0x10343f2
runtime.mapassign_faststr(0x1439380, 0xc0000df950, 0x14cdfa3, 0x4, 0x1)
        /usr/local/go/src/runtime/map_faststr.go:291 +0x3de fp=0xc00038b748 sp=0xc00038b6e0 pc=0x1014f5e
github.com/s8sg/goflow/eventhandler.(*TraceHandler).StartOperationSpan(0xc0002e2b40, 0xc000227090, 0x8, 0xc000376800, 0x14, 0x14cdfa3, 0x4)
        /Users/apple/go/pkg/mod/github.com/s8sg/goflow@v0.0.8/eventhandler/trace_handler.go:124 +0x223 fp=0xc00038b7d8 sp=0xc00038b748 pc=0x13107d3
github.com/s8sg/goflow/eventhandler.(*FaasEventHandler).ReportOperationStart(0xc00009c100, 0x14cdfa3, 0x4, 0xc000227090, 0x8, 0xc000376800, 0x14)
        /Users/apple/go/pkg/mod/github.com/s8sg/goflow@v0.0.8/eventhandler/faas_event_handler.go:66 +0x6b fp=0xc00038b820 sp=0xc00038b7d8 pc=0x130f4bb
github.com/faasflow/sdk/executor.(*FlowExecutor).executeNode(0xc00038bb98, 0xc0002268d0, 0x5, 0x8, 0xc00019a1a8, 0x1841590, 0x1, 0x0, 0x0)
        /Users/apple/go/pkg/mod/github.com/faasflow/sdk@v1.0.0/executor/executor.go:350 +0x702 fp=0xc00038b968 sp=0xc00038b820 pc=0x11338f2
github.com/faasflow/sdk/executor.(*FlowExecutor).Execute(0xc00038bb98, 0xc000380a00, 0x14d1ee9, 0xf, 0x18ac040, 0x203000, 0x203000)
        /Users/apple/go/pkg/mod/github.com/faasflow/sdk@v1.0.0/executor/executor.go:1266 +0xa8a fp=0xc00038bb00 sp=0xc00038b968 pc=0x113cbba
github.com/faasflow/runtime/controller/handler.ExecuteFlowHandler(0xc00038bcc8, 0xc0001f21e0, 0x15781e0, 0xc000128790, 0x0, 0x0)
        /Users/apple/go/pkg/mod/github.com/faasflow/runtime@v0.2.2/controller/handler/execute_flow_handler.go:28 +0x295 fp=0xc00038bc60 sp=0xc00038bb00 pc=0x1388395
github.com/s8sg/goflow/runtime.(*FlowRuntime).handleNewRequest(0xc000168100, 0xc0001f21e0, 0x6, 0xc0001f21e0)
        /Users/apple/go/pkg/mod/github.com/s8sg/goflow@v0.0.8/runtime/flow_runtime.go:204 +0xf2 fp=0xc00038bd08 sp=0xc00038bc60 pc=0x13d1bf2
github.com/s8sg/goflow/runtime.(*FlowRuntime).queueReceiver(0xc000168100, 0xc0000900a0, 0x15, 0xc00037e180, 0x6, 0x6, 0x2554c7bf5, 0x18800a0)
        /Users/apple/go/pkg/mod/github.com/s8sg/goflow@v0.0.8/runtime/flow_runtime.go:178 +0x37f fp=0xc00038bdd8 sp=0xc00038bd08 pc=0x13d195f
github.com/s8sg/goflow/runtime.(*FlowRuntime).queueReceiver-fm(0xc0000900a0, 0x15, 0xc00037e180, 0x6, 0x6, 0xc0001803c0, 0x0)
        /Users/apple/go/pkg/mod/github.com/s8sg/goflow@v0.0.8/runtime/flow_runtime.go:160 +0x5c fp=0xc00038be28 sp=0xc00038bdd8 pc=0x13d391c
github.com/benmanns/goworker.(*worker).run(0xc000208280, 0xc000066100, 0xc0000a2130)
        /Users/apple/go/pkg/mod/github.com/benmanns/goworker@v0.1.3/worker.go:154 +0x29f fp=0xc00038bed8 sp=0xc00038be28 pc=0x13852cf
github.com/benmanns/goworker.(*worker).work.func1(0xc0002260a0, 0xc000208280, 0xc0000a41e0)
        /Users/apple/go/pkg/mod/github.com/benmanns/goworker@v0.1.3/worker.go:108 +0x12a fp=0xc00038bfc8 sp=0xc00038bed8 pc=0x138708a
runtime.goexit()
        /usr/local/go/src/runtime/asm_amd64.s:1373 +0x1 fp=0xc00038bfd0 sp=0xc00038bfc8 pc=0x1064091
created by github.com/benmanns/goworker.(*worker).work
        /Users/apple/go/pkg/mod/github.com/benmanns/goworker@v0.1.3/worker.go:93 +0x1b4


Process finished with exit code 2

test code

package main

import (
	"fmt"
	"os"
	"time"

	"github.com/s8sg/goflow"
	flow "github.com/s8sg/goflow/flow"
)

// Workload function
func doSomething(data []byte, option map[string][]string) ([]byte, error) {
	fmt.Println("doSomething")
	time.Sleep(time.Second)
	return []byte(fmt.Sprintf("you said \"%s\"", string(data))), nil
}

// Define provide definition of the workflow
func DefineWorkflow(f *flow.Workflow, context *flow.Context) error {
	f.SyncNode().Apply("test", doSomething).Apply("test", doSomething).Apply("test", doSomething).Apply("test", doSomething)
	return nil
}

func main() {
	os.Setenv("enable_tracing", "true")
	for i := 0; i < 10; i++ {
		go func() {
			time.Sleep(10*time.Second)
			fmt.Println("start!")
			fs := &goflow.FlowService{
				RedisURL: "127.0.0.1:6379",
			}
			fs.Execute("myflow", &goflow.Request{
				Body: []byte("hallo"),
			})
		}()
	}
	fs := &goflow.FlowService{
		Port:              8080,
		RedisURL:          "127.0.0.1:6379",
		OpenTraceUrl:      "127.0.0.1:5775",
		WorkerConcurrency: 5,
	}
	err := fs.Register("myflow", DefineWorkflow)
	if err != nil {
	    panic(err)
	}
	err = fs.Start()
	if err != nil {
		panic(err)
	}
	
	select {}
}

Maybe TraceHandler's operationSpans concurrent operate.

@s8sg
Copy link
Owner

s8sg commented Oct 9, 2020

@LinkinStars thank you for reporting this issue. Can you please try with the latest release
https://github.com/s8sg/goflow/releases/tag/v0.1.0

@LinkinStars
Copy link
Author

I change to version v0.1.0, but the problem remains.

2020/10/09 19:04:51 Reporting span 7df3dc34375dfee6:50ce03eb333bc0ed:3ad27942d4ab172a:1
fatal error: concurrent map writesdoSomething


goroutine 67 [running]:
runtime.throw(0x15de707, 0x15)
        /usr/local/go/src/runtime/panic.go:1116 +0x72 fp=0xc000285678 sp=0xc000285648 pc=0x1034a02
runtime.mapassign_faststr(0x15310a0, 0xc0002de780, 0x15d772f, 0x4, 0x1)
        /usr/local/go/src/runtime/map_faststr.go:211 +0x3f7 fp=0xc0002856e0 sp=0xc000285678 pc=0x1015287
github.com/s8sg/goflow/eventhandler.(*TraceHandler).StartOperationSpan(0xc00015b180, 0xc000229028, 0x8, 0xc0004bbfe0, 0x14, 0x15d772f, 0x4)
        /Users/apple/go/pkg/mod/github.com/s8sg/goflow@v0.1.0/eventhandler/trace_handler.go:127 +0x223 fp=0xc000285770 sp=0xc0002856e0 pc=0x138d1e3
github.com/s8sg/goflow/eventhandler.(*GoFlowEventHandler).ReportOperationStart(0xc0000a81c0, 0x15d772f, 0x4, 0xc000229028, 0x8, 0xc0004bbfe0, 0x14)
        /Users/apple/go/pkg/mod/github.com/s8sg/goflow@v0.1.0/eventhandler/goflow_event_handler.go:66 +0x6b fp=0xc0002857b8 sp=0xc000285770 pc=0x138bd0b
github.com/faasflow/sdk/executor.(*FlowExecutor).executeNode(0xc000285b30, 0xc0000284a0, 0x5, 0x8, 0xc000402088, 0x1a2f9f0, 0x1, 0x0, 0x0)
        /Users/apple/go/pkg/mod/github.com/faasflow/sdk@v1.0.0/executor/executor.go:350 +0x702 fp=0xc000285900 sp=0xc0002857b8 pc=0x1160a52
github.com/faasflow/sdk/executor.(*FlowExecutor).Execute(0xc000285b30, 0xc0001774d0, 0x15db96f, 0xf, 0x1a9bd40, 0x203000, 0x203000)
        /Users/apple/go/pkg/mod/github.com/faasflow/sdk@v1.0.0/executor/executor.go:1266 +0xa8a fp=0xc000285a98 sp=0xc000285900 pc=0x1169d3a
github.com/faasflow/runtime/controller/handler.ExecuteFlowHandler(0xc000285c60, 0xc0003958c0, 0x16a8ec0, 0xc000154410, 0x0, 0x0)
        /Users/apple/go/pkg/mod/github.com/faasflow/runtime@v0.2.2/controller/handler/execute_flow_handler.go:28 +0x295 fp=0xc000285bf8 sp=0xc000285a98 pc=0x1423bc5
github.com/s8sg/goflow/runtime.(*FlowRuntime).handleNewRequest(0xc000112a20, 0xc0003958c0, 0x0, 0x0)
        /Users/apple/go/pkg/mod/github.com/s8sg/goflow@v0.1.0/runtime/flow_runtime.go:372 +0xf2 fp=0xc000285ca0 sp=0xc000285bf8 pc=0x14ac092
github.com/s8sg/goflow/runtime.(*FlowRuntime).handleRequest(0xc000112a20, 0xc0003958c0, 0xc00002844b, 0x3, 0x0, 0x0)
        /Users/apple/go/pkg/mod/github.com/s8sg/goflow@v0.1.0/runtime/flow_runtime.go:349 +0x10b fp=0xc000285d08 sp=0xc000285ca0 pc=0x14abe3b
github.com/s8sg/goflow/runtime.(*FlowRuntime).queueReceiver(0xc000112a20, 0xc0000a00c0, 0x1e, 0xc00022a1b0, 0x7, 0x9, 0x254815dd1, 0x1a6fd60)
        /Users/apple/go/pkg/mod/github.com/s8sg/goflow@v0.1.0/runtime/flow_runtime.go:324 +0x181 fp=0xc000285dd8 sp=0xc000285d08 pc=0x14ab881
github.com/s8sg/goflow/runtime.(*FlowRuntime).queueReceiver-fm(0xc0000a00c0, 0x1e, 0xc00022a1b0, 0x7, 0x9, 0xc0001aec60, 0x0)
        /Users/apple/go/pkg/mod/github.com/s8sg/goflow@v0.1.0/runtime/flow_runtime.go:304 +0x5c fp=0xc000285e28 sp=0xc000285dd8 pc=0x14af4fc
github.com/benmanns/goworker.(*worker).run(0xc0000a82c0, 0xc000066900, 0xc000021410)
        /Users/apple/go/pkg/mod/github.com/benmanns/goworker@v0.1.3/worker.go:154 +0x29f fp=0xc000285ed8 sp=0xc000285e28 pc=0x142067f
github.com/benmanns/goworker.(*worker).work.func1(0xc0000ac0d0, 0xc0000a82c0, 0xc00010a480)
        /Users/apple/go/pkg/mod/github.com/benmanns/goworker@v0.1.3/worker.go:108 +0x12a fp=0xc000285fc8 sp=0xc000285ed8 pc=0x142243a
runtime.goexit()
        /usr/local/go/src/runtime/asm_amd64.s:1373 +0x1 fp=0xc000285fd0 sp=0xc000285fc8 pc=0x10647c1
created by github.com/benmanns/goworker.(*worker).work
        /Users/apple/go/pkg/mod/github.com/benmanns/goworker@v0.1.3/worker.go:93 +0x1b4

@s8sg
Copy link
Owner

s8sg commented Oct 9, 2020

Ack. Let me check

@s8sg s8sg added bug Something isn't working help wanted Extra attention is needed labels Mar 4, 2021
@s8sg
Copy link
Owner

s8sg commented Aug 12, 2021

This is Fixed by #15

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants