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

database/gdb: fixed hasTable and getSoftFieldNameAndType use memory cache #3579

Closed
wants to merge 2 commits into from

Conversation

seth-shi
Copy link
Contributor

Fixed: #3574

  1. add Memory Cache
  2. hasTable from resultCache to memCache
  3. getSoftFieldNameAndType from defaultCache to db.memCache (db uses its own memory cache to avoid global competition)

@seth-shi
Copy link
Contributor Author

@seth-shi seth-shi closed this May 14, 2024
@seth-shi seth-shi reopened this May 14, 2024
@wln32 wln32 linked an issue May 14, 2024 that may be closed by this pull request
@gqcn
Copy link
Member

gqcn commented May 15, 2024

@seth-shi 没有必要加个MemCache,数据库就设置一个Cache即可,用于SQL查询缓存。至于一些内部的缓存数据例如数据表结构可以在内部使用内存缓存对象来缓存。在目前最新版本v2.7.1中,已经将数据表结构改为了gcache内存缓存。

@gqcn gqcn added the rejected The proposal or PR is not accepted, which might be conflicted with our design or plan. label May 15, 2024
@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


@seth-shi There is no need to add a MemCache, just set a Cache in the database for SQL query caching. As for some internal cache data such as data table structures, they can be cached internally using memory cache objects. In the latest version v2.7.1, the data table structure has been changed to gcache memory cache.

@gqcn gqcn closed this May 15, 2024
@seth-shi
Copy link
Contributor Author

@gqcn 请重新打开我的 pr, 谢谢. 直接用 gcache 有一个 bug, 有死锁. 应该使用我的方法, gdb 内部有自己的 cache.

bug:

gcache.GetOrSetFuncLock(ctx, key, function() {

     return dao.xxx.first()
})

由于外层使用了 gcache 上锁了, 内部 db 也使用, 导致死锁. 可以稳定复现

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


@gqcn Please reopen my pr, thank you. There is a bug in using gcache directly, and there is a deadlock. You should use my method, gdb has its own cache internally.

bug:

gcache.GetOrSetFuncLock(ctx, key, function() {

     return dao.xxx.first()
})

Since the outer layer uses gcache and is locked, the internal db is also used, resulting in a deadlock. It can be reproduced stably.

@gqcn
Copy link
Member

gqcn commented May 16, 2024

@gqcn 请重新打开我的 pr, 谢谢. 直接用 gcache 有一个 bug, 有死锁. 应该使用我的方法, gdb 内部有自己的 cache.

bug:

gcache.GetOrSetFuncLock(ctx, key, function() {

     return dao.xxx.first()
})

由于外层使用了 gcache 上锁了, 内部 db 也使用, 导致死锁. 可以稳定复现

你好,这个问题我已经在另一个pr中修复了:#3585 。同时修复还有租户端ORM缓存可能会碰撞的问题。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rejected The proposal or PR is not accepted, which might be conflicted with our design or plan.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

There is a deadlock in gcache db/gdb query table, field to cache
3 participants