Skip to content

[BUG] - concurrent map read and map write #61

@microhobby

Description

@microhobby

Describe the bug
A clear and concise description of what the bug is.

During mgc object-storage objects sync I'm having the follow stack trace:

Syncing files [00000/25706] █████████████████████████████████████████   0% | 0sfatal error: concurrent map read and map write

goroutine 85 [running]:
internal/runtime/maps.fatal({0xf4ed25?, 0x5088d2?})
        /opt/hostedtoolcache/go/1.24.2/x64/src/runtime/panic.go:1058 +0x18
github.com/MagaluCloud/magalu/mgc/sdk/static/object_storage/objects.processSyncFile({0x118c7a8, 0xc0005c4a50}, {0x5, 0x8, {0xc00063a448, 0x6}, {{0x0, 0x0}}}, {0x7ffcb343e4c8, 0x26}, ...)
        /home/runner/work/magalu/magalu/mgc/sdk/static/object_storage/objects/sync.go:295 +0x1be
github.com/MagaluCloud/magalu/mgc/sdk/static/object_storage/objects.syncWorker({0x118c7a8, 0xc0005c4a50}, {0x5, 0x8, {0xc00063a448, 0x6}, {{0x0, 0x0}}}, {0x7ffcb343e4c8, 0x26}, ...)
        /home/runner/work/magalu/magalu/mgc/sdk/static/object_storage/objects/sync.go:266 +0x1aa
github.com/MagaluCloud/magalu/mgc/sdk/static/object_storage/objects.processSyncFiles.func1()
        /home/runner/work/magalu/magalu/mgc/sdk/static/object_storage/objects/sync.go:230 +0x125
created by github.com/MagaluCloud/magalu/mgc/sdk/static/object_storage/objects.processSyncFiles in goroutine 1
        /home/runner/work/magalu/magalu/mgc/sdk/static/object_storage/objects/sync.go:228 +0x149

goroutine 1 [chan receive]:
github.com/MagaluCloud/magalu/mgc/sdk/static/object_storage/objects.processSyncFiles({0x118c7a8, 0xc0005c4a50}, {0x5, 0x8, {0xc00063a448, 0x6}, {{0x0, 0x0}}}, {0x7ffcb343e4c8, 0x26}, ...)
        /home/runner/work/magalu/magalu/mgc/sdk/static/object_storage/objects/sync.go:250 +0x35d
github.com/MagaluCloud/magalu/mgc/sdk/static/object_storage/objects.sync({0x118c770, 0xc0005bf920}, {{0x7ffcb343e4c8, 0x26}, {0xc00063a480, 0xb}, 0x0, 0x3e8}, {0x5, 0x8, ...})
        /home/runner/work/magalu/magalu/mgc/sdk/static/object_storage/objects/sync.go:107 +0x4ff
github.com/MagaluCloud/magalu/mgc/core.ReflectExecutorSpec[...].func1({0x118c770, 0xc0005bf920}, 0xc0005bf440, 0xc0005bf470)
        /home/runner/work/magalu/magalu/mgc/core/static_execute.go:121 +0x34c
github.com/MagaluCloud/magalu/mgc/core.(*SimpleExecutor).Execute(0xf?, {0x118c770?, 0xc0005bf920?}, 0xc0005f7270?, 0x1073960?)
        /home/runner/work/magalu/magalu/mgc/core/simple_executor.go:129 +0x3b
github.com/MagaluCloud/magalu/mgc/core.(*executeResultWrapper).Execute(0xc0004a9860, {0x118c770?, 0xc0005bf920?}, 0x5a0438?, 0x0?)
        /home/runner/work/magalu/magalu/mgc/core/types.go:153 +0x2e
github.com/MagaluCloud/magalu/mgc/cli/cmd.handleExecutorPre.func2()
        /home/runner/work/magalu/magalu/mgc/cli/cmd/handle_executor.go:127 +0x2c
github.com/MagaluCloud/magalu/mgc/core.(*RetryUntil).Run(0x117c3f0?, {0x118c770?, 0xc0005bf920?}, 0x117bea0?)
        /home/runner/work/magalu/magalu/mgc/core/retry_until.go:72 +0x62
github.com/MagaluCloud/magalu/mgc/cli/cmd.handleExecutorPre({0x118c770, 0xc0005bf860}, 0xdd9ae0?, 0xc0005caf08, {0x1198700, 0xc0004a9860}, 0xc0005bf440, 0xc0005bf470)
        /home/runner/work/magalu/magalu/mgc/cli/cmd/handle_executor.go:136 +0x4c9
github.com/MagaluCloud/magalu/mgc/cli/cmd.handleExecutor({0x118c770, 0xc0005bf830}, 0xc0001a3270, 0xc0005caf08, {0x1198700, 0xc0004a9860}, 0xc0005bf440, 0xc0005bf470)
        /home/runner/work/magalu/magalu/mgc/cli/cmd/handle_executor.go:154 +0xc5
github.com/MagaluCloud/magalu/mgc/cli/cmd.addAction.func1(0xc0005caf08, {0xc0005b71c0, 0x0, 0x4})
        /home/runner/work/magalu/magalu/mgc/cli/cmd/load_cmd_tree.go:323 +0x2b4
github.com/spf13/cobra.(*Command).execute(0xc0005caf08, {0xc0005b7180, 0x4, 0x4})
        /home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:1015 +0xa94
github.com/spf13/cobra.(*Command).ExecuteC(0xc0002b0008)
        /home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:1148 +0x40c
github.com/spf13/cobra.(*Command).Execute(...)
        /home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:1071
github.com/MagaluCloud/magalu/mgc/cli/cmd.Execute({0x117b950, 0x7})
        /home/runner/work/magalu/magalu/mgc/cli/cmd/root.go:163 +0xcff
main.main()
        /home/runner/work/magalu/magalu/mgc/cli/main.go:51 +0x74

goroutine 27 [select]:
github.com/jedib0t/go-pretty/v6/progress.(*Progress).Render(0xc0000345a0)
        /home/runner/go/pkg/mod/github.com/jedib0t/go-pretty/[email protected]/progress/render.go:22 +0x10f
created by github.com/MagaluCloud/magalu/mgc/cli/cmd.Execute in goroutine 1
        /home/runner/work/magalu/magalu/mgc/cli/cmd/root.go:155 +0xc85

goroutine 33 [select]:
github.com/jedib0t/go-pretty/v6/progress.(*Progress).watchTerminalSize(0xc0000345a0)
        /home/runner/go/pkg/mod/github.com/jedib0t/go-pretty/[email protected]/progress/progress.go:374 +0x96
created by github.com/jedib0t/go-pretty/v6/progress.(*Progress).initForRender in goroutine 27
        /home/runner/go/pkg/mod/github.com/jedib0t/go-pretty/[email protected]/progress/progress.go:358 +0x31b

goroutine 49 [select]:
atomicgo.dev/schedule.Every.func1()
        /home/runner/go/pkg/mod/atomicgo.dev/[email protected]/schedule.go:104 +0x7e
created by atomicgo.dev/schedule.Every in goroutine 1
        /home/runner/go/pkg/mod/atomicgo.dev/[email protected]/schedule.go:102 +0x14c

goroutine 81 [runnable]:
github.com/MagaluCloud/magalu/mgc/sdk/static/object_storage/objects.syncWorker({0x118c7a8, 0xc0005c4a50}, {0x5, 0x8, {0xc00063a448, 0x6}, {{0x0, 0x0}}}, {0x7ffcb343e4c8, 0x26}, ...)
        /home/runner/work/magalu/magalu/mgc/sdk/static/object_storage/objects/sync.go:261 +0xe5
github.com/MagaluCloud/magalu/mgc/sdk/static/object_storage/objects.processSyncFiles.func1()
        /home/runner/work/magalu/magalu/mgc/sdk/static/object_storage/objects/sync.go:230 +0x125
created by github.com/MagaluCloud/magalu/mgc/sdk/static/object_storage/objects.processSyncFiles in goroutine 1
        /home/runner/work/magalu/magalu/mgc/sdk/static/object_storage/objects/sync.go:228 +0x149

goroutine 29 [IO wait]:
internal/poll.runtime_pollWait(0x7fb39b67bdb8, 0x72)
        /opt/hostedtoolcache/go/1.24.2/x64/src/runtime/netpoll.go:351 +0x85
internal/poll.(*pollDesc).wait(0xc000b8c200?, 0xc000930000?, 0x0)
        /opt/hostedtoolcache/go/1.24.2/x64/src/internal/poll/fd_poll_runtime.go:84 +0x27
internal/poll.(*pollDesc).waitRead(...)
        /opt/hostedtoolcache/go/1.24.2/x64/src/internal/poll/fd_poll_runtime.go:89
internal/poll.(*FD).Read(0xc000b8c200, {0xc000930000, 0x2500, 0x2500})
        /opt/hostedtoolcache/go/1.24.2/x64/src/internal/poll/fd_unix.go:165 +0x27a
net.(*netFD).Read(0xc000b8c200, {0xc000930000?, 0xc00084c000?, 0x5?})
        /opt/hostedtoolcache/go/1.24.2/x64/src/net/fd_posix.go:55 +0x25
net.(*conn).Read(0xc000800000, {0xc000930000?, 0x7fb354bdc678?, 0x7fb39b9006c8?})
        /opt/hostedtoolcache/go/1.24.2/x64/src/net/net.go:194 +0x45
crypto/tls.(*atLeastReader).Read(0xc000e823f0, {0xc000930000?, 0x5?, 0xc0004cc9e8?})
        /opt/hostedtoolcache/go/1.24.2/x64/src/crypto/tls/conn.go:809 +0x3b
bytes.(*Buffer).ReadFrom(0xc0002269b8, {0x1185ce0, 0xc000e823f0})
        /opt/hostedtoolcache/go/1.24.2/x64/src/bytes/buffer.go:211 +0x98
crypto/tls.(*Conn).readFromUntil(0xc000226708, {0x11858c0, 0xc000800000}, 0x43d414?)
        /opt/hostedtoolcache/go/1.24.2/x64/src/crypto/tls/conn.go:831 +0xde
crypto/tls.(*Conn).readRecordOrCCS(0xc000226708, 0x0)
        /opt/hostedtoolcache/go/1.24.2/x64/src/crypto/tls/conn.go:629 +0x3cf
crypto/tls.(*Conn).readRecord(...)
        /opt/hostedtoolcache/go/1.24.2/x64/src/crypto/tls/conn.go:591
crypto/tls.(*Conn).Read(0xc000226708, {0xc0000d3000, 0x1000, 0xc0004d4660?})
        /opt/hostedtoolcache/go/1.24.2/x64/src/crypto/tls/conn.go:1385 +0x145
net/http.(*persistConn).Read(0xc0005ae240, {0xc0000d3000?, 0x79a985?, 0x1182ec0?})
        /opt/hostedtoolcache/go/1.24.2/x64/src/net/http/transport.go:2122 +0x47
bufio.(*Reader).fill(0xc000d40c00)
        /opt/hostedtoolcache/go/1.24.2/x64/src/bufio/bufio.go:113 +0x103
bufio.(*Reader).Peek(0xc000d40c00, 0x1)
        /opt/hostedtoolcache/go/1.24.2/x64/src/bufio/bufio.go:152 +0x53
net/http.(*persistConn).readLoop(0xc0005ae240)
        /opt/hostedtoolcache/go/1.24.2/x64/src/net/http/transport.go:2275 +0x172
created by net/http.(*Transport).dialConn in goroutine 51
        /opt/hostedtoolcache/go/1.24.2/x64/src/net/http/transport.go:1944 +0x174f

goroutine 30 [select]:
net/http.(*persistConn).writeLoop(0xc0005ae240)
        /opt/hostedtoolcache/go/1.24.2/x64/src/net/http/transport.go:2590 +0xe7
created by net/http.(*Transport).dialConn in goroutine 51
        /opt/hostedtoolcache/go/1.24.2/x64/src/net/http/transport.go:1945 +0x17a5

goroutine 82 [runnable]:
github.com/MagaluCloud/magalu/mgc/core/http.ClientFromContext({0x118c7a8, 0xc0005c4a50})
        /home/runner/work/magalu/magalu/mgc/core/http/http.go:46 +0x32
github.com/MagaluCloud/magalu/mgc/sdk/static/object_storage/common.SendRequestWithIgnoredHeaders({0x118c7a8, 0xc0005c4a50}, 0xc000f94000, 0xc00027f950)
        /home/runner/work/magalu/magalu/mgc/sdk/static/object_storage/common/session.go:102 +0x3f
github.com/MagaluCloud/magalu/mgc/sdk/static/object_storage/common.SendRequest(...)
        /home/runner/work/magalu/magalu/mgc/sdk/static/object_storage/common/session.go:133
github.com/MagaluCloud/magalu/mgc/sdk/static/object_storage/common.HeadFile({0x118c7a8, 0xc0005c4a50}, {0x5, 0x8, {0xc00063a448, 0x6}, {{0x0, 0x0}}}, {0xc000f8e000, 0x12}, ...)
        /home/runner/work/magalu/magalu/mgc/sdk/static/object_storage/common/head.go:47 +0x12e
github.com/MagaluCloud/magalu/mgc/sdk/static/object_storage/objects.headObject(...)
        /home/runner/work/magalu/magalu/mgc/sdk/static/object_storage/objects/head.go:32
github.com/MagaluCloud/magalu/mgc/sdk/static/object_storage/objects.getFileStats({0x118c7a8?, 0xc0005c4a50?}, {0xc000f8e000?, 0x0?}, {0x5, 0x8, {0xc00063a448, 0x6}, {{0x0, 0x0}}})
        /home/runner/work/magalu/magalu/mgc/sdk/static/object_storage/objects/sync.go:180 +0xda
github.com/MagaluCloud/magalu/mgc/sdk/static/object_storage/objects.processSyncFile({0x118c7a8, 0xc0005c4a50}, {0x5, 0x8, {0xc00063a448, 0x6}, {{0x0, 0x0}}}, {0x7ffcb343e4c8, 0x26}, ...)
        /home/runner/work/magalu/magalu/mgc/sdk/static/object_storage/objects/sync.go:299 +0x230
github.com/MagaluCloud/magalu/mgc/sdk/static/object_storage/objects.syncWorker({0x118c7a8, 0xc0005c4a50}, {0x5, 0x8, {0xc00063a448, 0x6}, {{0x0, 0x0}}}, {0x7ffcb343e4c8, 0x26}, ...)
        /home/runner/work/magalu/magalu/mgc/sdk/static/object_storage/objects/sync.go:266 +0x1aa
github.com/MagaluCloud/magalu/mgc/sdk/static/object_storage/objects.processSyncFiles.func1()
        /home/runner/work/magalu/magalu/mgc/sdk/static/object_storage/objects/sync.go:230 +0x125
created by github.com/MagaluCloud/magalu/mgc/sdk/static/object_storage/objects.processSyncFiles in goroutine 1
        /home/runner/work/magalu/magalu/mgc/sdk/static/object_storage/objects/sync.go:228 +0x149

goroutine 83 [running]:
        goroutine running on other thread; stack unavailable
created by github.com/MagaluCloud/magalu/mgc/sdk/static/object_storage/objects.processSyncFiles in goroutine 1
        /home/runner/work/magalu/magalu/mgc/sdk/static/object_storage/objects/sync.go:228 +0x149

goroutine 84 [runnable]:
github.com/MagaluCloud/magalu/mgc/core/config.(*Config).GetTempKeyPair(...)
        /home/runner/work/magalu/magalu/mgc/core/config/config.go:232
github.com/MagaluCloud/magalu/mgc/core/auth.(*Auth).AccessKeyPair(...)
        /home/runner/work/magalu/magalu/mgc/core/auth/auth.go:374
github.com/MagaluCloud/magalu/mgc/sdk/static/object_storage/common.SendRequestWithIgnoredHeaders({0x118c7a8, 0xc0005c4a50}, 0xc001032000, 0xc00027f950)
        /home/runner/work/magalu/magalu/mgc/sdk/static/object_storage/common/session.go:113 +0x115
github.com/MagaluCloud/magalu/mgc/sdk/static/object_storage/common.SendRequest(...)
        /home/runner/work/magalu/magalu/mgc/sdk/static/object_storage/common/session.go:133
github.com/MagaluCloud/magalu/mgc/sdk/static/object_storage/common.HeadFile({0x118c7a8, 0xc0005c4a50}, {0x5, 0x8, {0xc00063a448, 0x6}, {{0x0, 0x0}}}, {0xc000e1e070, 0x5b}, ...)
        /home/runner/work/magalu/magalu/mgc/sdk/static/object_storage/common/head.go:47 +0x12e
github.com/MagaluCloud/magalu/mgc/sdk/static/object_storage/objects.headObject(...)
        /home/runner/work/magalu/magalu/mgc/sdk/static/object_storage/objects/head.go:32
github.com/MagaluCloud/magalu/mgc/sdk/static/object_storage/objects.getFileStats({0x118c7a8?, 0xc0005c4a50?}, {0xc000e1e070?, 0xc000102fc0?}, {0x5, 0x8, {0xc00063a448, 0x6}, {{0x0, 0x0}}})
        /home/runner/work/magalu/magalu/mgc/sdk/static/object_storage/objects/sync.go:180 +0xda
github.com/MagaluCloud/magalu/mgc/sdk/static/object_storage/objects.processSyncFile({0x118c7a8, 0xc0005c4a50}, {0x5, 0x8, {0xc00063a448, 0x6}, {{0x0, 0x0}}}, {0x7ffcb343e4c8, 0x26}, ...)
        /home/runner/work/magalu/magalu/mgc/sdk/static/object_storage/objects/sync.go:299 +0x230
github.com/MagaluCloud/magalu/mgc/sdk/static/object_storage/objects.syncWorker({0x118c7a8, 0xc0005c4a50}, {0x5, 0x8, {0xc00063a448, 0x6}, {{0x0, 0x0}}}, {0x7ffcb343e4c8, 0x26}, ...)
        /home/runner/work/magalu/magalu/mgc/sdk/static/object_storage/objects/sync.go:266 +0x1aa
github.com/MagaluCloud/magalu/mgc/sdk/static/object_storage/objects.processSyncFiles.func1()
        /home/runner/work/magalu/magalu/mgc/sdk/static/object_storage/objects/sync.go:230 +0x125
created by github.com/MagaluCloud/magalu/mgc/sdk/static/object_storage/objects.processSyncFiles in goroutine 1
        /home/runner/work/magalu/magalu/mgc/sdk/static/object_storage/objects/sync.go:228 +0x149

goroutine 86 [select]:
github.com/MagaluCloud/magalu/mgc/sdk/static/object_storage/objects.processSyncFiles.func2()
        /home/runner/work/magalu/magalu/mgc/sdk/static/object_storage/objects/sync.go:237 +0x118
created by github.com/MagaluCloud/magalu/mgc/sdk/static/object_storage/objects.processSyncFiles in goroutine 1
        /home/runner/work/magalu/magalu/mgc/sdk/static/object_storage/objects/sync.go:234 +0x2fa

goroutine 87 [sync.WaitGroup.Wait]:
sync.runtime_SemacquireWaitGroup(0x0?)
        /opt/hostedtoolcache/go/1.24.2/x64/src/runtime/sema.go:110 +0x25
sync.(*WaitGroup).Wait(0x0?)
        /opt/hostedtoolcache/go/1.24.2/x64/src/sync/waitgroup.go:118 +0x48
github.com/MagaluCloud/magalu/mgc/sdk/static/object_storage/objects.processSyncFiles.func3()
        /home/runner/work/magalu/magalu/mgc/sdk/static/object_storage/objects/sync.go:246 +0x25
created by github.com/MagaluCloud/magalu/mgc/sdk/static/object_storage/objects.processSyncFiles in goroutine 1
        /home/runner/work/magalu/magalu/mgc/sdk/static/object_storage/objects/sync.go:245 +0x348

To Reproduce
Steps to reproduce the behavior:

  1. do a mgc object-storage objects sync

But this is not 100% reproducible. Happens, let's say, from 4 sync 1x.

Expected behavior
Not having this exception.

Desktop (please complete the following information):

  • OS: Debian
  • Version: Bookworm

Additional context
I'm using the latest version of the mgc. Let me know if you guys need more information.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions