Skip to content
This repository was 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.
This repository was archived by the owner on Sep 7, 2021. It is now read-only.

高并发下查询问题 #1404

@dollarkillerx

Description

@dollarkillerx
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 没有存在则入库,如果存在就更新。在第二次同步数据的时候出错。测试在单协程下没有问题

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions