Skip to content
This repository has been archived by the owner on Sep 7, 2021. It is now read-only.
This repository is currently being migrated. It's locked while the migration is in progress.

高并发下查询问题 #1404

Open
dollarkillerx opened this issue Aug 26, 2019 · 0 comments
Open

高并发下查询问题 #1404

dollarkillerx opened this issue Aug 26, 2019 · 0 comments

Comments

@dollarkillerx
Copy link

func init() {
	engine, e := xorm.NewEngine("mysql", "root:123456@(127.0.0.1:3306)/transfer?charset=utf8")
	if e != nil {
		panic(e.Error())
	}

	MbSql = engine

	engine2, e := xorm.NewEngine("mysql", "root:123456@(127.0.0.1:3306)/pre_video?charset=utf8")
	if e != nil {
		panic(e.Error())
	}
	e = engine2.Sync(
		new(datamodels.PreCartoon),
		new(datamodels.PreCartoonItem),
	)
	if e != nil {
		panic(e.Error())
	}

	MysqlEngine = engine2
}
                                 rw1.Lock()
				b, err := MysqlEngine.Where("sid = ?", v.Id).Get(&data_item)
				if err != nil {
					panic(err.Error())
				}
				rw1.Unlock()

高并发查询第二次入库查询下,b == false 没有开缓存

业务场景:同步数据,如果sid 没有存在则入库,如果存在就更新。在第二次同步数据的时候出错。测试在单协程下没有问题

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant