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

Data races detected from Batch function #448

Closed
judehung opened this issue Aug 17, 2020 · 0 comments · Fixed by #449
Closed

Data races detected from Batch function #448

judehung opened this issue Aug 17, 2020 · 0 comments · Fixed by #449
Labels
bug Something isn't working

Comments

@judehung
Copy link
Member

When running go test -race against app-functions-sdk-go, go race detector reports several data race errors for Batch function. A data race happens when two goroutines access the same variable concurrently, and at least one of the accesses is a write. Theoretically, data races imply unpredictable behavior and may lead to strange result.

Follow procedures below to use go race detector to observe data races from Batch function:

  1. checkout repositories
    git clone git@github.com:edgexfoundry/app-functions-sdk-go.git

  2. Change directory to the local repository
    cd app-functions-sdk-go/pkg/transforms

  3. Run go race detector
    go test -race -run=Batch

There will be 12 data races detected, as shown below:

level=DEBUG ts=2020-08-17T09:16:55.803808848Z app=app_functions_sdk_go source=batch.go:82 msg="Batching Data"
level=DEBUG ts=2020-08-17T09:16:55.806018228Z app=app_functions_sdk_go source=batch.go:82 msg="Batching Data"
level=DEBUG ts=2020-08-17T09:16:55.808341363Z app=app_functions_sdk_go source=batch.go:82 msg="Batching Data"
level=DEBUG ts=2020-08-17T09:16:55.812420589Z app=app_functions_sdk_go source=batch.go:126 msg="Forwarding Batched Data..."
level=DEBUG ts=2020-08-17T09:16:55.813717189Z app=app_functions_sdk_go source=batch.go:82 msg="Batching Data"
level=DEBUG ts=2020-08-17T09:16:55.814893239Z app=app_functions_sdk_go source=batch.go:82 msg="Batching Data"
level=DEBUG ts=2020-08-17T09:16:55.815793888Z app=app_functions_sdk_go source=batch.go:82 msg="Batching Data"
level=DEBUG ts=2020-08-17T09:16:55.816501539Z app=app_functions_sdk_go source=batch.go:126 msg="Forwarding Batched Data..."
level=DEBUG ts=2020-08-17T09:16:55.818030328Z app=app_functions_sdk_go source=batch.go:82 msg="Batching Data"
level=DEBUG ts=2020-08-17T09:16:57.819365569Z app=app_functions_sdk_go source=batch.go:82 msg="Batching Data"
level=DEBUG ts=2020-08-17T09:16:57.819607413Z app=app_functions_sdk_go source=batch.go:99 msg="Timer has elapsed"
level=DEBUG ts=2020-08-17T09:16:57.819226902Z app=app_functions_sdk_go source=batch.go:82 msg="Batching Data"
==================
WARNING: DATA RACE
Read at 0x00c0000fb9f8 by goroutine 12:
github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms.(*BatchConfig).Batch()
/home/judehung/MyDev/EdgeX/app-functions-sdk-go/pkg/transforms/batch.go:88 +0x24f
github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms.TestBatchInTimeAndCountMode_TimeElapsed.func2()
/home/judehung/MyDev/EdgeX/app-functions-sdk-go/pkg/transforms/batch_test.go:72 +0xf7
Previous write at 0x00c0000fb9f8 by goroutine 11:
github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms.(*BatchConfig).Batch()
/home/judehung/MyDev/EdgeX/app-functions-sdk-go/pkg/transforms/batch.go:88 +0x2f1
github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms.TestBatchInTimeAndCountMode_TimeElapsed.func1()
/home/judehung/MyDev/EdgeX/app-functions-sdk-go/pkg/transforms/batch_test.go:64 +0x111
Goroutine 12 (running) created at:
github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms.TestBatchInTimeAndCountMode_TimeElapsed()
/home/judehung/MyDev/EdgeX/app-functions-sdk-go/pkg/transforms/batch_test.go:70 +0x188
testing.tRunner()
/usr/local/go/src/testing/testing.go:909 +0x199
Goroutine 11 (running) created at:
github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms.TestBatchInTimeAndCountMode_TimeElapsed()
/home/judehung/MyDev/EdgeX/app-functions-sdk-go/pkg/transforms/batch_test.go:59 +0x148
testing.tRunner()
/usr/local/go/src/testing/testing.go:909 +0x199
==================
==================
WARNING: DATA RACE
Read at 0x00c000140040 by goroutine 12:
runtime.growslice()
/usr/local/go/src/runtime/slice.go:76 +0x0
github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms.(*BatchConfig).Batch()
/home/judehung/MyDev/EdgeX/app-functions-sdk-go/pkg/transforms/batch.go:88 +0x930
github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms.TestBatchInTimeAndCountMode_TimeElapsed.func2()
/home/judehung/MyDev/EdgeX/app-functions-sdk-go/pkg/transforms/batch_test.go:72 +0xf7
Previous write at 0x00c000140040 by goroutine 11:
github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms.(*BatchConfig).Batch()
/home/judehung/MyDev/EdgeX/app-functions-sdk-go/pkg/transforms/batch.go:88 +0x2a6
github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms.TestBatchInTimeAndCountMode_TimeElapsed.func1()
/home/judehung/MyDev/EdgeX/app-functions-sdk-go/pkg/transforms/batch_test.go:64 +0x111
Goroutine 12 (running) created at:
github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms.TestBatchInTimeAndCountMode_TimeElapsed()
/home/judehung/MyDev/EdgeX/app-functions-sdk-go/pkg/transforms/batch_test.go:70 +0x188
testing.tRunner()
/usr/local/go/src/testing/testing.go:909 +0x199
Goroutine 11 (running) created at:
github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms.TestBatchInTimeAndCountMode_TimeElapsed()
/home/judehung/MyDev/EdgeX/app-functions-sdk-go/pkg/transforms/batch_test.go:59 +0x148
testing.tRunner()
/usr/local/go/src/testing/testing.go:909 +0x199
==================
==================
WARNING: DATA RACE
Read at 0x00c0000fba28 by goroutine 12:
github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms.(*BatchConfig).Batch()
/home/judehung/MyDev/EdgeX/app-functions-sdk-go/pkg/transforms/batch.go:92 +0x66a
github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms.TestBatchInTimeAndCountMode_TimeElapsed.func2()
/home/judehung/MyDev/EdgeX/app-functions-sdk-go/pkg/transforms/batch_test.go:72 +0xf7
Previous write at 0x00c0000fba28 by goroutine 11:
github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms.(*BatchConfig).Batch()
/home/judehung/MyDev/EdgeX/app-functions-sdk-go/pkg/transforms/batch.go:93 +0x6d5
github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms.TestBatchInTimeAndCountMode_TimeElapsed.func1()
/home/judehung/MyDev/EdgeX/app-functions-sdk-go/pkg/transforms/batch_test.go:64 +0x111
Goroutine 12 (running) created at:
github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms.TestBatchInTimeAndCountMode_TimeElapsed()
/home/judehung/MyDev/EdgeX/app-functions-sdk-go/pkg/transforms/batch_test.go:70 +0x188
testing.tRunner()
/usr/local/go/src/testing/testing.go:909 +0x199
Goroutine 11 (running) created at:
github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms.TestBatchInTimeAndCountMode_TimeElapsed()
/home/judehung/MyDev/EdgeX/app-functions-sdk-go/pkg/transforms/batch_test.go:59 +0x148
testing.tRunner()
/usr/local/go/src/testing/testing.go:909 +0x199
==================
level=DEBUG ts=2020-08-17T09:16:57.830369452Z app=app_functions_sdk_go source=batch.go:126 msg="Forwarding Batched Data..."
==================
WARNING: DATA RACE
Read at 0x00c00016c0a8 by goroutine 13:
runtime.growslice()
/usr/local/go/src/runtime/slice.go:76 +0x0
github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms.(*BatchConfig).Batch()
/home/judehung/MyDev/EdgeX/app-functions-sdk-go/pkg/transforms/batch.go:88 +0x930
github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms.TestBatchInTimeAndCountMode_TimeElapsed.func3()
/home/judehung/MyDev/EdgeX/app-functions-sdk-go/pkg/transforms/batch_test.go:78 +0xf7
Previous write at 0x00c00016c0a8 by goroutine 12:
github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms.(*BatchConfig).Batch()
/home/judehung/MyDev/EdgeX/app-functions-sdk-go/pkg/transforms/batch.go:88 +0x2a6
github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms.TestBatchInTimeAndCountMode_TimeElapsed.func2()
/home/judehung/MyDev/EdgeX/app-functions-sdk-go/pkg/transforms/batch_test.go:72 +0xf7
Goroutine 13 (running) created at:
github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms.TestBatchInTimeAndCountMode_TimeElapsed()
/home/judehung/MyDev/EdgeX/app-functions-sdk-go/pkg/transforms/batch_test.go:76 +0x1c8
testing.tRunner()
/usr/local/go/src/testing/testing.go:909 +0x199
Goroutine 12 (finished) created at:
github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms.TestBatchInTimeAndCountMode_TimeElapsed()
/home/judehung/MyDev/EdgeX/app-functions-sdk-go/pkg/transforms/batch_test.go:70 +0x188
testing.tRunner()
/usr/local/go/src/testing/testing.go:909 +0x199
==================
level=DEBUG ts=2020-08-17T09:16:59.840562732Z app=app_functions_sdk_go source=batch.go:99 msg="Timer has elapsed"
level=DEBUG ts=2020-08-17T09:16:59.84389498Z app=app_functions_sdk_go source=batch.go:126 msg="Forwarding Batched Data..."
--- FAIL: TestBatchInTimeAndCountMode_TimeElapsed (4.03s)
testing.go:853: race detected during execution of test
level=DEBUG ts=2020-08-17T09:16:59.845968618Z app=app_functions_sdk_go source=batch.go:82 msg="Batching Data"
level=DEBUG ts=2020-08-17T09:17:09.847338348Z app=app_functions_sdk_go source=batch.go:82 msg="Batching Data"
==================
WARNING: DATA RACE
Read at 0x00c0001b0028 by goroutine 20:
github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms.(*BatchConfig).Batch()
/home/judehung/MyDev/EdgeX/app-functions-sdk-go/pkg/transforms/batch.go:88 +0x24f
github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms.TestBatchInTimeAndCountMode_CountMet.func2()
/home/judehung/MyDev/EdgeX/app-functions-sdk-go/pkg/transforms/batch_test.go:110 +0x119
Previous write at 0x00c0001b0028 by goroutine 19:
github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms.(*BatchConfig).Batch()
/home/judehung/MyDev/EdgeX/app-functions-sdk-go/pkg/transforms/batch.go:88 +0x2f1
github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms.TestBatchInTimeAndCountMode_CountMet.func1()
/home/judehung/MyDev/EdgeX/app-functions-sdk-go/pkg/transforms/batch_test.go:100 +0x10b
Goroutine 20 (running) created at:
github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms.TestBatchInTimeAndCountMode_CountMet()
/home/judehung/MyDev/EdgeX/app-functions-sdk-go/pkg/transforms/batch_test.go:104 +0x1e9
testing.tRunner()
/usr/local/go/src/testing/testing.go:909 +0x199
Goroutine 19 (running) created at:
github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms.TestBatchInTimeAndCountMode_CountMet()
/home/judehung/MyDev/EdgeX/app-functions-sdk-go/pkg/transforms/batch_test.go:95 +0x19f
testing.tRunner()
/usr/local/go/src/testing/testing.go:909 +0x199
==================
==================
WARNING: DATA RACE
Read at 0x00c000140100 by goroutine 20:
runtime.growslice()
/usr/local/go/src/runtime/slice.go:76 +0x0
github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms.(*BatchConfig).Batch()
/home/judehung/MyDev/EdgeX/app-functions-sdk-go/pkg/transforms/batch.go:88 +0x930
github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms.TestBatchInTimeAndCountMode_CountMet.func2()
/home/judehung/MyDev/EdgeX/app-functions-sdk-go/pkg/transforms/batch_test.go:110 +0x119
Previous write at 0x00c000140100 by goroutine 19:
github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms.(*BatchConfig).Batch()
/home/judehung/MyDev/EdgeX/app-functions-sdk-go/pkg/transforms/batch.go:88 +0x2a6
github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms.TestBatchInTimeAndCountMode_CountMet.func1()
/home/judehung/MyDev/EdgeX/app-functions-sdk-go/pkg/transforms/batch_test.go:100 +0x10b
Goroutine 20 (running) created at:
github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms.TestBatchInTimeAndCountMode_CountMet()
/home/judehung/MyDev/EdgeX/app-functions-sdk-go/pkg/transforms/batch_test.go:104 +0x1e9
testing.tRunner()
/usr/local/go/src/testing/testing.go:909 +0x199
Goroutine 19 (running) created at:
github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms.TestBatchInTimeAndCountMode_CountMet()
/home/judehung/MyDev/EdgeX/app-functions-sdk-go/pkg/transforms/batch_test.go:95 +0x19f
testing.tRunner()
/usr/local/go/src/testing/testing.go:909 +0x199
==================
==================
WARNING: DATA RACE
Read at 0x00c0001b0058 by goroutine 20:
github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms.(*BatchConfig).Batch()
/home/judehung/MyDev/EdgeX/app-functions-sdk-go/pkg/transforms/batch.go:92 +0x66a
github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms.TestBatchInTimeAndCountMode_CountMet.func2()
/home/judehung/MyDev/EdgeX/app-functions-sdk-go/pkg/transforms/batch_test.go:110 +0x119
Previous write at 0x00c0001b0058 by goroutine 19:
github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms.(*BatchConfig).Batch()
/home/judehung/MyDev/EdgeX/app-functions-sdk-go/pkg/transforms/batch.go:93 +0x6d5
github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms.TestBatchInTimeAndCountMode_CountMet.func1()
/home/judehung/MyDev/EdgeX/app-functions-sdk-go/pkg/transforms/batch_test.go:100 +0x10b
Goroutine 20 (running) created at:
github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms.TestBatchInTimeAndCountMode_CountMet()
/home/judehung/MyDev/EdgeX/app-functions-sdk-go/pkg/transforms/batch_test.go:104 +0x1e9
testing.tRunner()
/usr/local/go/src/testing/testing.go:909 +0x199
Goroutine 19 (running) created at:
github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms.TestBatchInTimeAndCountMode_CountMet()
/home/judehung/MyDev/EdgeX/app-functions-sdk-go/pkg/transforms/batch_test.go:95 +0x19f
testing.tRunner()
/usr/local/go/src/testing/testing.go:909 +0x199
==================
level=DEBUG ts=2020-08-17T09:17:19.847729541Z app=app_functions_sdk_go source=batch.go:82 msg="Batching Data"
==================
WARNING: DATA RACE
Read at 0x00c000184258 by goroutine 22:
runtime.growslice()
/usr/local/go/src/runtime/slice.go:76 +0x0
github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms.(*BatchConfig).Batch()
/home/judehung/MyDev/EdgeX/app-functions-sdk-go/pkg/transforms/batch.go:88 +0x930
github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms.TestBatchInTimeAndCountMode_CountMet.func3()
/home/judehung/MyDev/EdgeX/app-functions-sdk-go/pkg/transforms/batch_test.go:117 +0x10e
Previous write at 0x00c000184258 by goroutine 20:
github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms.(*BatchConfig).Batch()
/home/judehung/MyDev/EdgeX/app-functions-sdk-go/pkg/transforms/batch.go:88 +0x2a6
github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms.TestBatchInTimeAndCountMode_CountMet.func2()
/home/judehung/MyDev/EdgeX/app-functions-sdk-go/pkg/transforms/batch_test.go:110 +0x119
Goroutine 22 (running) created at:
github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms.TestBatchInTimeAndCountMode_CountMet()
/home/judehung/MyDev/EdgeX/app-functions-sdk-go/pkg/transforms/batch_test.go:114 +0x233
testing.tRunner()
/usr/local/go/src/testing/testing.go:909 +0x199
Goroutine 20 (finished) created at:
github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms.TestBatchInTimeAndCountMode_CountMet()
/home/judehung/MyDev/EdgeX/app-functions-sdk-go/pkg/transforms/batch_test.go:104 +0x1e9
testing.tRunner()
/usr/local/go/src/testing/testing.go:909 +0x199
==================
level=DEBUG ts=2020-08-17T09:17:19.851779861Z app=app_functions_sdk_go source=batch.go:126 msg="Forwarding Batched Data..."
level=DEBUG ts=2020-08-17T09:17:19.851867039Z app=app_functions_sdk_go source=batch.go:97 msg="Batch count has been reached"
level=DEBUG ts=2020-08-17T09:17:19.856755629Z app=app_functions_sdk_go source=batch.go:126 msg="Forwarding Batched Data..."
--- FAIL: TestBatchInTimeAndCountMode_CountMet (20.01s)
testing.go:853: race detected during execution of test
level=DEBUG ts=2020-08-17T09:17:19.858550276Z app=app_functions_sdk_go source=batch.go:82 msg="Batching Data"
level=DEBUG ts=2020-08-17T09:17:19.858650663Z app=app_functions_sdk_go source=batch.go:82 msg="Batching Data"
level=DEBUG ts=2020-08-17T09:17:19.858713311Z app=app_functions_sdk_go source=batch.go:82 msg="Batching Data"
==================
WARNING: DATA RACE
Read at 0x00c0001b0098 by goroutine 27:
github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms.(*BatchConfig).Batch()
/home/judehung/MyDev/EdgeX/app-functions-sdk-go/pkg/transforms/batch.go:88 +0x24f
github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms.TestBatchInTimeMode.func3()
/home/judehung/MyDev/EdgeX/app-functions-sdk-go/pkg/transforms/batch_test.go:153 +0xf7
Previous write at 0x00c0001b0098 by goroutine 25:
github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms.(*BatchConfig).Batch()
/home/judehung/MyDev/EdgeX/app-functions-sdk-go/pkg/transforms/batch.go:88 +0x2f1
github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms.TestBatchInTimeMode.func1()
/home/judehung/MyDev/EdgeX/app-functions-sdk-go/pkg/transforms/batch_test.go:139 +0x111
Goroutine 27 (running) created at:
github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms.TestBatchInTimeMode()
/home/judehung/MyDev/EdgeX/app-functions-sdk-go/pkg/transforms/batch_test.go:151 +0x1bf
testing.tRunner()
/usr/local/go/src/testing/testing.go:909 +0x199
Goroutine 25 (running) created at:
github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms.TestBatchInTimeMode()
/home/judehung/MyDev/EdgeX/app-functions-sdk-go/pkg/transforms/batch_test.go:133 +0x13f
testing.tRunner()
/usr/local/go/src/testing/testing.go:909 +0x199
==================
==================
WARNING: DATA RACE
Read at 0x00c000172200 by goroutine 27:
runtime.growslice()
/usr/local/go/src/runtime/slice.go:76 +0x0
github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms.(*BatchConfig).Batch()
/home/judehung/MyDev/EdgeX/app-functions-sdk-go/pkg/transforms/batch.go:88 +0x930
github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms.TestBatchInTimeMode.func3()
/home/judehung/MyDev/EdgeX/app-functions-sdk-go/pkg/transforms/batch_test.go:153 +0xf7
Previous write at 0x00c000172200 by goroutine 25:
github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms.(*BatchConfig).Batch()
/home/judehung/MyDev/EdgeX/app-functions-sdk-go/pkg/transforms/batch.go:88 +0x2a6
github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms.TestBatchInTimeMode.func1()
/home/judehung/MyDev/EdgeX/app-functions-sdk-go/pkg/transforms/batch_test.go:139 +0x111
Goroutine 27 (running) created at:
github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms.TestBatchInTimeMode()
/home/judehung/MyDev/EdgeX/app-functions-sdk-go/pkg/transforms/batch_test.go:151 +0x1bf
testing.tRunner()
/usr/local/go/src/testing/testing.go:909 +0x199
Goroutine 25 (running) created at:
github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms.TestBatchInTimeMode()
/home/judehung/MyDev/EdgeX/app-functions-sdk-go/pkg/transforms/batch_test.go:133 +0x13f
testing.tRunner()
/usr/local/go/src/testing/testing.go:909 +0x199
==================
==================
WARNING: DATA RACE
Read at 0x00c0001b00c8 by goroutine 27:
github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms.(*BatchConfig).Batch()
/home/judehung/MyDev/EdgeX/app-functions-sdk-go/pkg/transforms/batch.go:92 +0x66a
github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms.TestBatchInTimeMode.func3()
/home/judehung/MyDev/EdgeX/app-functions-sdk-go/pkg/transforms/batch_test.go:153 +0xf7
Previous write at 0x00c0001b00c8 by goroutine 25:
github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms.(*BatchConfig).Batch()
/home/judehung/MyDev/EdgeX/app-functions-sdk-go/pkg/transforms/batch.go:93 +0x6d5
github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms.TestBatchInTimeMode.func1()
/home/judehung/MyDev/EdgeX/app-functions-sdk-go/pkg/transforms/batch_test.go:139 +0x111
Goroutine 27 (running) created at:
github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms.TestBatchInTimeMode()
/home/judehung/MyDev/EdgeX/app-functions-sdk-go/pkg/transforms/batch_test.go:151 +0x1bf
testing.tRunner()
/usr/local/go/src/testing/testing.go:909 +0x199
Goroutine 25 (running) created at:
github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms.TestBatchInTimeMode()
/home/judehung/MyDev/EdgeX/app-functions-sdk-go/pkg/transforms/batch_test.go:133 +0x13f
testing.tRunner()
/usr/local/go/src/testing/testing.go:909 +0x199
==================
==================
WARNING: DATA RACE
Read at 0x00c0001843d8 by goroutine 26:
runtime.growslice()
/usr/local/go/src/runtime/slice.go:76 +0x0
github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms.(*BatchConfig).Batch()
/home/judehung/MyDev/EdgeX/app-functions-sdk-go/pkg/transforms/batch.go:88 +0x930
github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms.TestBatchInTimeMode.func2()
/home/judehung/MyDev/EdgeX/app-functions-sdk-go/pkg/transforms/batch_test.go:146 +0xf7
Previous write at 0x00c0001843d8 by goroutine 27:
github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms.(*BatchConfig).Batch()
/home/judehung/MyDev/EdgeX/app-functions-sdk-go/pkg/transforms/batch.go:88 +0x2a6
github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms.TestBatchInTimeMode.func3()
/home/judehung/MyDev/EdgeX/app-functions-sdk-go/pkg/transforms/batch_test.go:153 +0xf7
Goroutine 26 (running) created at:
github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms.TestBatchInTimeMode()
/home/judehung/MyDev/EdgeX/app-functions-sdk-go/pkg/transforms/batch_test.go:144 +0x17f
testing.tRunner()
/usr/local/go/src/testing/testing.go:909 +0x199
Goroutine 27 (finished) created at:
github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms.TestBatchInTimeMode()
/home/judehung/MyDev/EdgeX/app-functions-sdk-go/pkg/transforms/batch_test.go:151 +0x1bf
testing.tRunner()
/usr/local/go/src/testing/testing.go:909 +0x199
==================
level=DEBUG ts=2020-08-17T09:17:22.866415935Z app=app_functions_sdk_go source=batch.go:99 msg="Timer has elapsed"
level=DEBUG ts=2020-08-17T09:17:22.878805722Z app=app_functions_sdk_go source=batch.go:126 msg="Forwarding Batched Data..."
--- FAIL: TestBatchInTimeMode (3.02s)
testing.go:853: race detected during execution of test
FAIL
Found 12 data race(s)
exit status 66
FAIL github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms 28.088s

@lenny-goodell lenny-goodell linked a pull request Aug 17, 2020 that will close this issue
12 tasks
@rsdmike rsdmike added the bug Something isn't working label Aug 21, 2020
lenny-goodell pushed a commit that referenced this issue Sep 3, 2020
After analyzing those data races as listed in #448, there're two
variables shall be in atomic operation to avoid data races:

1. batchData
2. timerActive

This commit from the batchData [][]byte to atomicBatchData to avoid data
race and update timerActive from bool to atomicBool to avoid data race

Signed-off-by: Jude Hung <jude@iotechsys.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants