cache/find bug #1048

Open
opened 3 years ago by vlorc · 2 comments
vlorc commented 3 years ago (Migrated from github.com)
Owner
  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 3 years ago (Migrated from github.com)
Owner

解决办法:

  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 3 years ago (Migrated from github.com)
Owner
  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 2 years ago
lunny added the
feature/cache
label 3 months ago
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date

No due date set.

Dependencies

This issue currently doesn't have any dependencies.

Loading…
There is no content yet.