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

Race condition #30

Open
huntrist opened this issue Jun 9, 2022 · 0 comments
Open

Race condition #30

huntrist opened this issue Jun 9, 2022 · 0 comments

Comments

@huntrist
Copy link

huntrist commented Jun 9, 2022

func InitQQBot() (err error) {

	botgo.SetSessionManager(
		remote.New(
			GetRedisConn(),
			remote.WithClusterKey(Settings.QQBotManagerKey),
		),
	)
	
	botgo.SetLogger(Logger)

	token := botoken.BotToken(uint64(Settings.QQBotAppId), Settings.QQBotAppToken)
	api := botgo.NewOpenAPI(token).WithTimeout(3 * time.Second)
	ctx := context.Background()
	ws, err := api.WS(ctx, nil, "")
	if err != nil {
		return err
	}

	intent := botws.RegisterHandlers(HandleAtMessage)

	ws.Shards = 10
	manager := botgo.NewSessionManager()
	err = manager.Start(ws, token, &intent)
	if err != nil {
		return err
	}

	return err
}

==================
WARNING: DATA RACE
Read at 0x00c00095c5a0 by goroutine 88:
  github.com/tencent-connect/botgo/dto.(*Session).String()
      /home/LeaderOne/go/pkg/mod/github.com/tencent-connect/[email protected]/dto/websocket.go:43 +0x64
  fmt.(*pp).handleMethods()
      /usr/local/go/src/fmt/print.go:626 +0x6cf
  fmt.(*pp).printArg()
      /usr/local/go/src/fmt/print.go:709 +0xca9
  fmt.(*pp).doPrintf()
      /usr/local/go/src/fmt/print.go:1026 +0x46f
  fmt.Sprintf()
      /usr/local/go/src/fmt/print.go:219 +0x67
  src.ProjectOne.com/ProjectServer/record.DEBUGF()
      /mnt/d/Projects/ProjectOne/src/ProjectServer/record/record.go:96 +0x54
  src.ProjectOne.com/ProjectServer/qqbot.BotLogger.Debugf()
      /mnt/d/Projects/ProjectOne/src/ProjectServer/qqbot/logger.go:25 +0x76
  src.ProjectOne.com/ProjectServer/qqbot.(*BotLogger).Debugf()
      <autogenerated>:1 +0x42
  github.com/tencent-connect/botgo/log.Debugf()
      /home/LeaderOne/go/pkg/mod/github.com/tencent-connect/[email protected]/log/log.go:29 +0x451
  github.com/tencent-connect/botgo/websocket/client.(*Client).Listening()
      /home/LeaderOne/go/pkg/mod/github.com/tencent-connect/[email protected]/websocket/client/client.go:108 +0x392
  github.com/tencent-connect/botgo/sessions/remote.(*RedisManager).newConnect()
      /home/LeaderOne/go/pkg/mod/github.com/tencent-connect/[email protected]/sessions/remote/remote.go:160 +0x6c1
  github.com/tencent-connect/botgo/sessions/remote.(*RedisManager).consume·dwrap·3()
      /home/LeaderOne/go/pkg/mod/github.com/tencent-connect/[email protected]/sessions/remote/remote.go:116 +0x9c

Previous write at 0x00c00095c5a0 by goroutine 95:
  github.com/tencent-connect/botgo/websocket/client.(*Client).readyHandler()
      /home/LeaderOne/go/pkg/mod/github.com/tencent-connect/[email protected]/websocket/client/client.go:269 +0x332
  github.com/tencent-connect/botgo/websocket/client.(*Client).listenMessageAndHandle()
      /home/LeaderOne/go/pkg/mod/github.com/tencent-connect/[email protected]/websocket/client/client.go:217 +0x41d
  github.com/tencent-connect/botgo/websocket/client.(*Client).Listening·dwrap·3()
      /home/LeaderOne/go/pkg/mod/github.com/tencent-connect/[email protected]/websocket/client/client.go:76 +0x39

Goroutine 88 (running) created at:
  github.com/tencent-connect/botgo/sessions/remote.(*RedisManager).consume()
      /home/LeaderOne/go/pkg/mod/github.com/tencent-connect/[email protected]/sessions/remote/remote.go:116 +0x94c
  github.com/tencent-connect/botgo/sessions/remote.(*RedisManager).Start()
      /home/LeaderOne/go/pkg/mod/github.com/tencent-connect/[email protected]/sessions/remote/remote.go:89 +0xa66
  src.ProjectOne.com/ProjectServer/qqbot.InitQQBot()
      /mnt/d/Projects/ProjectOne/src/ProjectServer/qqbot/basic.go:49 +0x4a6
  src.ProjectOne.com/ProjectServer/qqbot.Init.func1()
      /mnt/d/Projects/ProjectOne/src/ProjectServer/qqbot/qqbot.go:16 +0x5d

Goroutine 95 (running) created at:
  github.com/tencent-connect/botgo/websocket/client.(*Client).Listening()
      /home/LeaderOne/go/pkg/mod/github.com/tencent-connect/[email protected]/websocket/client/client.go:76 +0x19c
  github.com/tencent-connect/botgo/sessions/remote.(*RedisManager).newConnect()
      /home/LeaderOne/go/pkg/mod/github.com/tencent-connect/[email protected]/sessions/remote/remote.go:160 +0x6c1
  github.com/tencent-connect/botgo/sessions/remote.(*RedisManager).consume·dwrap·3()
      /home/LeaderOne/go/pkg/mod/github.com/tencent-connect/[email protected]/sessions/remote/remote.go:116 +0x9c
==================
==================
WARNING: DATA RACE
Read at 0x00c00095c5f4 by goroutine 88:
  github.com/tencent-connect/botgo/dto.(*Session).String()
      /home/LeaderOne/go/pkg/mod/github.com/tencent-connect/[email protected]/dto/websocket.go:43 +0x9a
  fmt.(*pp).handleMethods()
      /usr/local/go/src/fmt/print.go:626 +0x6cf
  fmt.(*pp).printArg()
      /usr/local/go/src/fmt/print.go:709 +0xca9
  fmt.(*pp).doPrintf()
      /usr/local/go/src/fmt/print.go:1026 +0x46f
  fmt.Sprintf()
      /usr/local/go/src/fmt/print.go:219 +0x67
  src.ProjectOne.com/ProjectServer/record.DEBUGF()
      /mnt/d/Projects/ProjectOne/src/ProjectServer/record/record.go:96 +0x54
  src.ProjectOne.com/ProjectServer/qqbot.BotLogger.Debugf()
      /mnt/d/Projects/ProjectOne/src/ProjectServer/qqbot/logger.go:25 +0x76
  src.ProjectOne.com/ProjectServer/qqbot.(*BotLogger).Debugf()
      <autogenerated>:1 +0x42
  github.com/tencent-connect/botgo/log.Debugf()
      /home/LeaderOne/go/pkg/mod/github.com/tencent-connect/[email protected]/log/log.go:29 +0x451
  github.com/tencent-connect/botgo/websocket/client.(*Client).Listening()
      /home/LeaderOne/go/pkg/mod/github.com/tencent-connect/[email protected]/websocket/client/client.go:108 +0x392
  github.com/tencent-connect/botgo/sessions/remote.(*RedisManager).newConnect()
      /home/LeaderOne/go/pkg/mod/github.com/tencent-connect/[email protected]/sessions/remote/remote.go:160 +0x6c1
  github.com/tencent-connect/botgo/sessions/remote.(*RedisManager).consume·dwrap·3()
      /home/LeaderOne/go/pkg/mod/github.com/tencent-connect/[email protected]/sessions/remote/remote.go:116 +0x9c

Previous write at 0x00c00095c5f4 by goroutine 95:
  github.com/tencent-connect/botgo/websocket/client.(*Client).readyHandler()
      /home/LeaderOne/go/pkg/mod/github.com/tencent-connect/[email protected]/websocket/client/client.go:270 +0x3d0
  github.com/tencent-connect/botgo/websocket/client.(*Client).listenMessageAndHandle()
      /home/LeaderOne/go/pkg/mod/github.com/tencent-connect/[email protected]/websocket/client/client.go:217 +0x41d
  github.com/tencent-connect/botgo/websocket/client.(*Client).Listening·dwrap·3()
      /home/LeaderOne/go/pkg/mod/github.com/tencent-connect/[email protected]/websocket/client/client.go:76 +0x39

Goroutine 88 (running) created at:
  github.com/tencent-connect/botgo/sessions/remote.(*RedisManager).consume()
      /home/LeaderOne/go/pkg/mod/github.com/tencent-connect/[email protected]/sessions/remote/remote.go:116 +0x94c
  github.com/tencent-connect/botgo/sessions/remote.(*RedisManager).Start()
      /home/LeaderOne/go/pkg/mod/github.com/tencent-connect/[email protected]/sessions/remote/remote.go:89 +0xa66
  src.ProjectOne.com/ProjectServer/qqbot.InitQQBot()
      /mnt/d/Projects/ProjectOne/src/ProjectServer/qqbot/basic.go:49 +0x4a6
  src.ProjectOne.com/ProjectServer/qqbot.Init.func1()
      /mnt/d/Projects/ProjectOne/src/ProjectServer/qqbot/qqbot.go:16 +0x5d

Goroutine 95 (running) created at:
  github.com/tencent-connect/botgo/websocket/client.(*Client).Listening()
      /home/LeaderOne/go/pkg/mod/github.com/tencent-connect/[email protected]/websocket/client/client.go:76 +0x19c
  github.com/tencent-connect/botgo/sessions/remote.(*RedisManager).newConnect()
      /home/LeaderOne/go/pkg/mod/github.com/tencent-connect/[email protected]/sessions/remote/remote.go:160 +0x6c1
  github.com/tencent-connect/botgo/sessions/remote.(*RedisManager).consume·dwrap·3()
      /home/LeaderOne/go/pkg/mod/github.com/tencent-connect/[email protected]/sessions/remote/remote.go:116 +0x9c
==================
==================
WARNING: DATA RACE
Read at 0x00c00095c5f8 by goroutine 88:
  github.com/tencent-connect/botgo/dto.(*Session).String()
      /home/LeaderOne/go/pkg/mod/github.com/tencent-connect/[email protected]/dto/websocket.go:43 +0xcc
  fmt.(*pp).handleMethods()
      /usr/local/go/src/fmt/print.go:626 +0x6cf
  fmt.(*pp).printArg()
      /usr/local/go/src/fmt/print.go:709 +0xca9
  fmt.(*pp).doPrintf()
      /usr/local/go/src/fmt/print.go:1026 +0x46f
  fmt.Sprintf()
      /usr/local/go/src/fmt/print.go:219 +0x67
  src.ProjectOne.com/ProjectServer/record.DEBUGF()
      /mnt/d/Projects/ProjectOne/src/ProjectServer/record/record.go:96 +0x54
  src.ProjectOne.com/ProjectServer/qqbot.BotLogger.Debugf()
      /mnt/d/Projects/ProjectOne/src/ProjectServer/qqbot/logger.go:25 +0x76
  src.ProjectOne.com/ProjectServer/qqbot.(*BotLogger).Debugf()
      <autogenerated>:1 +0x42
  github.com/tencent-connect/botgo/log.Debugf()
      /home/LeaderOne/go/pkg/mod/github.com/tencent-connect/[email protected]/log/log.go:29 +0x451
  github.com/tencent-connect/botgo/websocket/client.(*Client).Listening()
      /home/LeaderOne/go/pkg/mod/github.com/tencent-connect/[email protected]/websocket/client/client.go:108 +0x392
  github.com/tencent-connect/botgo/sessions/remote.(*RedisManager).newConnect()
      /home/LeaderOne/go/pkg/mod/github.com/tencent-connect/[email protected]/sessions/remote/remote.go:160 +0x6c1
  github.com/tencent-connect/botgo/sessions/remote.(*RedisManager).consume·dwrap·3()
      /home/LeaderOne/go/pkg/mod/github.com/tencent-connect/[email protected]/sessions/remote/remote.go:116 +0x9c

Previous write at 0x00c00095c5f8 by goroutine 95:
  github.com/tencent-connect/botgo/websocket/client.(*Client).readyHandler()
      /home/LeaderOne/go/pkg/mod/github.com/tencent-connect/[email protected]/websocket/client/client.go:271 +0x44f
  github.com/tencent-connect/botgo/websocket/client.(*Client).listenMessageAndHandle()
      /home/LeaderOne/go/pkg/mod/github.com/tencent-connect/[email protected]/websocket/client/client.go:217 +0x41d
  github.com/tencent-connect/botgo/websocket/client.(*Client).Listening·dwrap·3()
      /home/LeaderOne/go/pkg/mod/github.com/tencent-connect/[email protected]/websocket/client/client.go:76 +0x39

Goroutine 88 (running) created at:
  github.com/tencent-connect/botgo/sessions/remote.(*RedisManager).consume()
      /home/LeaderOne/go/pkg/mod/github.com/tencent-connect/[email protected]/sessions/remote/remote.go:116 +0x94c
  github.com/tencent-connect/botgo/sessions/remote.(*RedisManager).Start()
      /home/LeaderOne/go/pkg/mod/github.com/tencent-connect/[email protected]/sessions/remote/remote.go:89 +0xa66
  src.ProjectOne.com/ProjectServer/qqbot.InitQQBot()
      /mnt/d/Projects/ProjectOne/src/ProjectServer/qqbot/basic.go:49 +0x4a6
  src.ProjectOne.com/ProjectServer/qqbot.Init.func1()
      /mnt/d/Projects/ProjectOne/src/ProjectServer/qqbot/qqbot.go:16 +0x5d

Goroutine 95 (running) created at:
  github.com/tencent-connect/botgo/websocket/client.(*Client).Listening()
      /home/LeaderOne/go/pkg/mod/github.com/tencent-connect/[email protected]/websocket/client/client.go:76 +0x19c
  github.com/tencent-connect/botgo/sessions/remote.(*RedisManager).newConnect()
      /home/LeaderOne/go/pkg/mod/github.com/tencent-connect/[email protected]/sessions/remote/remote.go:160 +0x6c1
  github.com/tencent-connect/botgo/sessions/remote.(*RedisManager).consume·dwrap·3()
      /home/LeaderOne/go/pkg/mod/github.com/tencent-connect/[email protected]/sessions/remote/remote.go:116 +0x9c
==================
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant