Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Let backends declare thread_safe and allow concurrent backend calls in Store (follow-up to #206)

未关闭
#208 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
35/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
冷清
技术栈
python

调研方向

首先阅读 BackendBase 和 Store 的实现,重点关注 _stats、writethrough-cache 计账、_cache_disabled 以及后端的 load/store/delete 调用。比较此处描述的主后端和缓存后端要求。当线程安全声明和经过审查的设计能够保护 Store 的记账,同时允许安全地并发调用后端时,即表示完成。

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

描述

Follow-up to #206 / #207 (from Claude, reviewed by TW).

#207 serializes all Store operations with one internal lock. That is correct and sufficient for today's callers (borg's #9988 pack store-thread issues one op at a time), but it means the store can never execute two backend calls concurrently - even on backends where that would be safe and beneficial.

Idea

Let a backend declare itself safe for concurrent calls, and let Store exploit that:

  1. Declaration: BackendBase.thread_safe: bool = False class attribute. posixfs can honestly set True (independent syscalls per call). sftp/rest/rclone/s3 stay False with their single session - or later become True via a connection pool.
  2. Store side: this is not just "skip the lock" - the Store's own bookkeeping (_stats Counter updates, writethrough-cache accounting, _cache_disabled) needs protection regardless of the backend. The finer-grained design: keep a small lock for stats/cache mutations, but allow the backend calls themselves (backend.load/store/delete/...) to run outside the lock when backend.thread_safe is true.
  3. Cache backend: the cache backend is a second, independent backend with its own thread_safe - concurrent primary + cache calls need both declarations (or per-backend locks).

Why bother (later)

  • multiple concurrent uploads to hide per-request latency on cloud backends (the "riskier follow-up" scoped out of borgbackup/borg#9988),
  • parallel prefetch on extract,
  • concurrent range-reads for get_many on packs living in different objects.

None of these exist as callers today, which is why #207 deliberately kept the simple unconditional lock. This issue exists so the design above does not get lost, and to be picked up once a real parallel-I/O caller shows up.

主要语言
Python
星标
26
派生
9
平均合并
2 小时 22 分钟
30 天内合并 PR
12

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

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

borgbackup/borgstore 的其他 Issue

查看 borgbackup/borgstore 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

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