cache/find bug #1048

Open
opened 2018-07-24 06:51:48 +00:00 by vlorc · 2 comments
vlorc commented 2018-07-24 06:51:48 +00:00 (Migrated from github.com)
  1. 使用ClearCache清除cache,bean清理,sql无清理
    RedisCacher.ClearIds 清除xorm:sql:TableName:CRC32的key
    c.delObjects(c.getSqlKey(tableName, "*")),"*"的CRC32明显无法匹配find时的sql,导致sql无法清除

  2. Session.cacheFind 由于上述sql没有清除
    在cache bean未命中时session.queryRows没有执行所有Start,LimitN没有清零
    session.NoCache().Table(tableName).find(beans)生成的语句为:select * from table id in(?,?,?,) offset 10 limit 由于offset/limit存在最终查不出数据

1. 使用ClearCache清除cache,bean清理,sql无清理 RedisCacher.ClearIds 清除xorm:sql:TableName:CRC32的key c.delObjects(c.getSqlKey(tableName, "\*")),"\*"的CRC32明显无法匹配find时的sql,导致sql无法清除 2. Session.cacheFind 由于上述sql没有清除 在cache bean未命中时session.queryRows没有执行所有Start,LimitN没有清零 session.NoCache().Table(tableName).find(beans)生成的语句为:select * from table id in(?,?,?,) offset 10 limit 由于offset/limit存在最终查不出数据
vlorc commented 2018-07-24 06:58:46 +00:00 (Migrated from github.com)

解决办法:

  1. 在c.delObjects(c.getSqlKey(tableName, "*")) 不使用CRC32,以xorm:sql:TableName:*去删除
  2. 在session.NoCache().Table(tableName).find(beans)前一句session.statement.Start = 0
解决办法: 1. 在c.delObjects(c.getSqlKey(tableName, "*")) 不使用CRC32,以xorm:sql:TableName:*去删除 2. 在session.NoCache().Table(tableName).find(beans)前一句session.statement.Start = 0
vlorc commented 2018-07-24 07:01:13 +00:00 (Migrated from github.com)
  1. at RedisCacher.ClearIds:205

    c.delObjects(fmt.Sprintf("xorm:sql:%s:*", tableName))
    
  2. at Session.cacheFind:433

     session.statement.Start = 0
     err = session.NoCache().Table(tableName).find(beans)
     if err != nil {
     	return err
     }
1. at RedisCacher.ClearIds:205 c.delObjects(fmt.Sprintf("xorm:sql:%s:*", tableName)) 2. at Session.cacheFind:433 session.statement.Start = 0 err = session.NoCache().Table(tableName).find(beans) if err != nil { return err }
lunny added this to the 1.3.0 milestone 2020-03-04 02:23:20 +00:00
lunny added the
feature
cache
label 2021-09-07 08:10:34 +00:00
lunny modified the milestone from 1.3.0 to 2.0.0 2022-01-25 04:00:40 +00:00
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: xorm/xorm#1048
No description provided.