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

__ENV should not be shared between VUs #1328

Closed
mstoykov opened this issue Feb 11, 2020 · 0 comments · Fixed by #1329
Closed

__ENV should not be shared between VUs #1328

mstoykov opened this issue Feb 11, 2020 · 0 comments · Fixed by #1329
Assignees
Labels

Comments

@mstoykov
Copy link
Contributor

Environment

  • k6 version: v0.26.0, but probably all versions

Expected Behavior

changing __ENV in one VU should not change it in another

Actual Behavior

it changes :)

Steps to Reproduce the Problem

  1. script.js:
console.log(__ENV.something)
__ENV.something = Math.random()
export default function() {}

2.k6 run script.js

$ k6 run -u 5 script.js

          /\      |‾‾|  /‾‾/  /‾/
     /\  /  \     |  |_/  /  / /
    /  \/    \    |      |  /  ‾‾\
   /          \   |  |‾\  \ | (_) |
  / __________ \  |__|  \__\ \___/ .io

INFO[0001] undefined
WARN[0001] All iterations (1 in this test run) are shared between all VUs, so some of the 5 VUs will not execute even a single iteration!
INFO[0001] 0.44183025883093746
INFO[0001] 0.1016693686145117
INFO[0001] 0.3351747792404137
INFO[0001] 0.9595724221546064
INFO[0001] 0.6634652530245149
  execution: local
     output: -
     script: env.js

    duration: -,  iterations: 1
         vus: 5, max: 5

INFO[0001] 0.9781430971546957
INFO[0001] 0.5929989320809331
    done [==========================================================] 1 / 1

    data_received........: 0 B 0 B/s
    data_sent............: 0 B 0 B/s
    iteration_duration...: avg=3.78µs min=3.78µs med=3.78µs max=3.78µs p(90)=3.78µs p(95)=3.78µs
    iterations...........: 1   0/s
    vus..................: 5   min=5 max=5
    vus_max..............: 5   min=5 max=5

For the record running

export default function() {
        __ENV.something = Math.random()
}

reliably panics 2 VUs and 2000iterations with


fatal error: concurrent map writes----------------------------------] starting

goroutine 32 [running]:
runtime.throw(0xeaad9b, 0x15)
        /home/mstoykov/.gvm/gos/go1.13.5/src/runtime/panic.go:774 +0x72 fp=0xc002229760 sp=0xc002229730 pc=0x430a92
runtime.mapassign(0xd53940, 0xc00039d350, 0xc002ca5440, 0x40b79b)
        /home/mstoykov/.gvm/gos/go1.13.5/src/runtime/map.go:588 +0x5c3 fp=0xc0022297e8 sp=0xc002229760 pc=0x410143
reflect.mapassign(0xd53940, 0xc00039d350, 0xc002ca5440, 0xc002ca5450)
        /home/mstoykov/.gvm/gos/go1.13.5/src/runtime/map.go:1329 +0x3f fp=0xc002229818 sp=0xc0022297e8 pc=0x411b2f
reflect.Value.SetMapIndex(0xd53940, 0xc00039d350, 0x15, 0xd1c520, 0xc002ca5440, 0x98, 0xd1c520, 0xc002ca5450, 0x98)
        /home/mstoykov/.gvm/gos/go1.13.5/src/reflect/value.go:1679 +0x268 fp=0xc002229898 sp=0xc002229818 pc=0x4c72d8
github.com/loadimpact/k6/vendor/github.com/dop251/goja.(*objectGoMapReflect).putStr(0xc001ee3130, 0xc000042972, 0x9, 0x10cf580, 0xc002b08b10, 0x1)
        /home/mstoykov/.gvm/pkgsets/go1.13.5/global/src/github.com/loadimpact/k6/vendor/github.com/dop251/goja/object_gomap_reflect.go:107 +0x100 fp=0xc002229908 sp=0xc002229898 pc=0x8d6300
github.com/loadimpact/k6/vendor/github.com/dop251/goja.setPropStrict.exec(0xc000042972, 0x9, 0xc00042b930)
        /home/mstoykov/.gvm/pkgsets/go1.13.5/global/src/github.com/loadimpact/k6/vendor/github.com/dop251/goja/vm.go:1069 +0xde fp=0xc002229960 sp=0xc002229908 pc=0x8fcd7e
github.com/loadimpact/k6/vendor/github.com/dop251/goja.(*setPropStrict).exec(0xc002308c60, 0xc00042b930)
        <autogenerated>:1 +0x4f fp=0xc002229988 sp=0xc002229960 pc=0x921c9f
github.com/loadimpact/k6/vendor/github.com/dop251/goja.(*vm).run(0xc00042b930)
        /home/mstoykov/.gvm/pkgsets/go1.13.5/global/src/github.com/loadimpact/k6/vendor/github.com/dop251/goja/vm.go:289 +0x99 fp=0xc0022299c8 sp=0xc002229988 pc=0x8f8409
github.com/loadimpact/k6/vendor/github.com/dop251/goja.(*funcObject).Call(0xc001f4f500, 0x10cf760, 0x1990980, 0xc002ca5430, 0x1, 0x1, 0x10cf760, 0x1990980)
        /home/mstoykov/.gvm/pkgsets/go1.13.5/global/src/github.com/loadimpact/k6/vendor/github.com/dop251/goja/func.go:130 +0x2cc fp=0xc002229a40 sp=0xc0022299c8 pc=0x8ce70c
github.com/loadimpact/k6/vendor/github.com/dop251/goja.(*funcObject).Call-fm(0x10cf760, 0x1990980, 0xc002ca5430, 0x1, 0x1, 0x100000000203000, 0xc002229b60)
        /home/mstoykov/.gvm/pkgsets/go1.13.5/global/src/github.com/loadimpact/k6/vendor/github.com/dop251/goja/func.go:102 +0x48 fp=0xc002229a90 sp=0xc002229a40 pc=0x916d28
github.com/loadimpact/k6/vendor/github.com/dop251/goja.AssertFunction.func1.2()
        /home/mstoykov/.gvm/pkgsets/go1.13.5/global/src/github.com/loadimpact/k6/vendor/github.com/dop251/goja/runtime.go:1461 +0x96 fp=0xc002229b08 sp=0xc002229a90 pc=0x90bf66
github.com/loadimpact/k6/vendor/github.com/dop251/goja.(*vm).try(0xc00042b930, 0xc002229c50, 0x0)
        /home/mstoykov/.gvm/pkgsets/go1.13.5/global/src/github.com/loadimpact/k6/vendor/github.com/dop251/goja/vm.go:379 +0x147 fp=0xc002229bf0 sp=0xc002229b08 pc=0x8f8a27
github.com/loadimpact/k6/vendor/github.com/dop251/goja.AssertFunction.func1(0x10cf760, 0x1990980, 0xc002ca5430, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0)
        /home/mstoykov/.gvm/pkgsets/go1.13.5/global/src/github.com/loadimpact/k6/vendor/github.com/dop251/goja/runtime.go:1460 +0x13a fp=0xc002229ca0 sp=0xc002229bf0 pc=0x90c0ea
github.com/loadimpact/k6/js.(*VU).runFn(0xc0026c03c0, 0x10c25a0, 0xc0003cae40, 0xc000af1380, 0x1, 0xc000556b80, 0xc002ca5430, 0x1, 0x1, 0x432800, ...)
        /home/mstoykov/.gvm/pkgsets/go1.13.5/global/src/github.com/loadimpact/k6/js/runner.go:477 +0x398 fp=0xc002229da0 sp=0xc002229ca0 pc=0xc4e998
github.com/loadimpact/k6/js.(*VU).RunOnce(0xc0026c03c0, 0x10c25a0, 0xc0003cae40, 0x0, 0x0)
        /home/mstoykov/.gvm/pkgsets/go1.13.5/global/src/github.com/loadimpact/k6/js/runner.go:427 +0x277 fp=0xc002229ec8 sp=0xc002229da0 pc=0xc4e317
github.com/loadimpact/k6/core/local.(*vuHandle).run(0xc0017dbb00, 0xc0000f6070, 0xc00045c240, 0xc0000d2420)
        /home/mstoykov/.gvm/pkgsets/go1.13.5/global/src/github.com/loadimpact/k6/core/local/local.go:70 +0x152 fp=0xc002229f90 sp=0xc002229ec8 pc=0xc643b2
github.com/loadimpact/k6/core/local.(*Executor).scale.func1(0xc0017dbb00, 0xc000a50b40, 0xc00045c240, 0xc0000d2420)
        /home/mstoykov/.gvm/pkgsets/go1.13.5/global/src/github.com/loadimpact/k6/core/local/local.go:349 +0x4d fp=0xc002229fc0 sp=0xc002229f90 pc=0xc6792d
runtime.goexit()
        /home/mstoykov/.gvm/gos/go1.13.5/src/runtime/asm_amd64.s:1357 +0x1 fp=0xc002229fc8 sp=0xc002229fc0 pc=0x45de91
created by github.com/loadimpact/k6/core/local.(*Executor).scale
        /home/mstoykov/.gvm/pkgsets/go1.13.5/global/src/github.com/loadimpact/k6/core/local/local.go:348 +0x328
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.

1 participant