server: Discovery store is only persisted on clean shutdown

未关闭 适合新手
#663 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
76/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
python
领域
backend, databases

调研方向

阅读 server/app/services/run_discovery.py 和 DiscoveryStore.to_file() 的实现,然后检查 post_all_asset_links_by_id 和 delete_all_asset_links_by_id,了解它们如何更新内存中的存储。检查持久化模式如何配置 storage_path;如果服务异常停止后,成功的 POST 或 DELETE 仍然可用,则表示完成。如果不选择在写入时持久化,README 中仅修改文档的方案是一个替代选项。

由索引模型根据 Issue 内容生成。

描述

bug server

The discovery service writes its store to storage_path only in an
atexit hook:

https://github.com/eclipse-basyx/basyx-python-sdk/blob/2773ac069d3163cbbd32c3c634813d38bbe521ad/server/app/services/run_discovery.py#L38-L43

The write handlers post_all_asset_links_by_id and
delete_all_asset_links_by_id only change the in-memory dicts.

The discovery_standalone README describes a "Persistent Mode" but
does not say that changes are written only at shutdown:

https://github.com/eclipse-basyx/basyx-python-sdk/blob/2773ac069d3163cbbd32c3c634813d38bbe521ad/server/example_configurations/discovery_standalone/README.md#L31-L43

Expected behavior: In persistent mode, a successful POST or DELETE
on /lookup/shells/{aasIdentifier} survives a crash of the service.

Actual behavior: Changes reach the disk only on a clean shutdown.
If the process is killed (OOM, docker kill, host crash, uWSGI worker
crash), all asset links registered since startup are lost.

Environment: develop @ 2773ac06, image built from
server/docker/discovery/Dockerfile with storage_path set.

Options:

  1. Persist on every write: call DiscoveryStore.to_file() at the end
    of both write handlers and drop the atexit hook. to_file()
    already writes a temp file and uses os.replace(), so the write is
    atomic.
  2. Keep the current behavior and document it: state in the README
    that changes are saved only on a clean shutdown and that a crash
    loses everything since the last start.

Option 1 is a small change and makes "persistent mode" mean what users
expect, so I would prefer it.

主要语言
Python
星标
107
派生
61
平均合并
49 分钟
30 天内合并 PR
3

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

eclipse-basyx/basyx-python-sdk 的其他 Issue

查看 eclipse-basyx/basyx-python-sdk 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。