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

多服务器共用数据库时,新增或删除存储,文件列表刷新失效 #6833

Closed
4 tasks done
ForSourceCodeAnalysis opened this issue Jul 21, 2024 · 2 comments
Closed
4 tasks done
Labels
bug Something isn't working stale No activity for more than 30 days

Comments

@ForSourceCodeAnalysis
Copy link

Please make sure of the following things

  • I have read the documentation.
    我已经阅读了文档

  • I'm sure there are no duplicate issues or discussions.
    我确定没有重复的issue或讨论。

  • I'm sure it's due to AList and not something else(such as Network ,Dependencies or Operational).
    我确定是AList的问题,而不是其他原因(例如网络依赖操作)。

  • I'm sure this issue is not fixed in the latest version.
    我确定这个问题在最新版本中没有被修复。

AList Version / AList 版本

v3.35.0

Driver used / 使用的存储驱动

123pan

Describe the bug / 问题描述

这个问题之前有人提出过,但是当时认为是缓存问题
希望可以在页面上手动清理缓存
这里在描述一次,复现步骤如下:

  1. A,B服务共用数据库
  2. A中新增存储F,B在存储管理里面刷新列表,可以看到A新增的F,但是在文件列表刷新,无法看到存储F挂载的目录,必须要重启B的alist服务才可以
  3. 同理,如果A,B都有存储F,A中删除存储F,B中文件列表也不会删除F的挂载目录

Reproduction / 复现链接

问题已经定位到了,原因如下:

  1. 获取存储列表是直接从数据库获取的,所以每次获取存储列表都是最新的
  2. 获取文件列表时,使用的是内存中的storagesMap变量,而内存是和服务器绑定的,所以就导致获取文件列表使用的不是最新的
  3. 本来通过存储管理界面的Relaod All按钮可以更新内存中的storagesMap,但是更新出现了问题
    func LoadAllStorages(c *gin.Context) { storages, err := db.GetEnabledStorages() if err != nil { log.Errorf("failed get enabled storages: %+v", err) common.ErrorResp(c, err, 500, true) return } conf.StoragesLoaded = false go func(storages []model.Storage) { //这里的更新逻辑是:先卸载存储,再挂载 //而storages是从数据库获取的,这就意味着,A服务删除了存储F,在B服务更新时, //只会更新存在的,而F不在数据库中,也就不会动F,所以更新后,F依然存在storagesMap中 //A中新增存储F时,B中更新会先从storagesMap中查询F的挂载目录,查询不到,直接报错…… //这个逻辑有问题,本身就是要更新storagesMap,却使用了旧的storagesMap查询…… for _, storage := range storages { storageDriver, err := op.GetStorageByMountPath(storage.MountPath) if err != nil { log.Errorf("failed get storage driver: %+v", err) continue } // drop the storage in the driver if err := storageDriver.Drop(context.Background()); err != nil { log.Errorf("failed drop storage: %+v", err) continue } if err := op.LoadStorage(context.Background(), storage); err != nil { log.Errorf("failed get enabled storages: %+v", err) continue } log.Infof("success load storage: [%s], driver: [%s]", storage.MountPath, storage.Driver) } conf.StoragesLoaded = true }(storages) common.SuccessResp(c) }

Config / 配置

Logs / 日志

[GIN] 2024/07/21 - 02:43:16 | 200 | 28.722787ms | 192.168.31.40 | POST "/api/admin/storage/load_all"
�[36mINFO�[0m[2024-07-21 02:43:17] success load storage: [/123pan4764], driver: [123Pan]
�[36mINFO�[0m[2024-07-21 02:43:17] success load storage: [/crypt123pan4764], driver: [Crypt]
�[36mINFO�[0m[2024-07-21 02:43:18] success load storage: [/baidubdusername], driver: [BaiduNetdisk]
�[36mINFO�[0m[2024-07-21 02:43:18] success load storage: [/baiduluopo], driver: [BaiduNetdisk]
�[36mINFO�[0m[2024-07-21 02:43:18] success load storage: [/cryptBdLp], driver: [Crypt]
�[36mINFO�[0m[2024-07-21 02:43:19] success load storage: [/123panlu], driver: [123Pan]
�[36mINFO�[0m[2024-07-21 02:43:19] success load storage: [/crypt123panlu], driver: [Crypt]
�[36mINFO�[0m[2024-07-21 02:43:19] success load storage: [/local_us], driver: [Local]
�[31mERRO�[0m[2024-07-21 02:43:19] failed get storage driver: no mount path for an storage is: /ali
github.com/alist-org/alist/v3/internal/op.GetStorageByMountPath
/home/sfy/work/alist/internal/op/storage.go:37
github.com/alist-org/alist/v3/server/handles.LoadAllStorages.func1
/home/sfy/work/alist/server/handles/storage.go:135
runtime.goexit
/usr/local/go/src/runtime/asm_amd64.s:1650

Copy link

stale bot commented Sep 3, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale No activity for more than 30 days label Sep 3, 2024
Copy link

Hello @, this issue was closed due to inactive more than 52 days. You can reopen or recreate it if you think it should continue. Thank you for your contributions again.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Sep 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working stale No activity for more than 30 days
Projects
None yet
Development

No branches or pull requests

1 participant