HTTP: shared_set returns null for a write it refused, the same as for a write it made

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

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
48/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
c
领域
backend

调研方向

Read the shared_set and shared_incr implementations, their tests, and docs/BUILTINS.md; the issue does not name source or test paths. Start by tracing how each builtin enforces the byte cap and handles invalid values, then check how raised errors reach routes. Done when the listed cases raise as specified, preserve existing values, produce a 500 when uncaught, and the documentation describes the errors.

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

描述

area:http kind:decision

Found beside #2380. Run on a make server-db build of 68dbb67e (phase2-numbers). The same code is on main; it was not run there.

What happens

shared_set returns null when it has stored the value. It also returns null when the write would pass the store's byte cap (EIGS_HTTP_SHARED_MAX_BYTES, 64 MiB by default) and nothing was stored:

big is ""
i is 0
loop while i < 300:
    big is big + "x"
    i is i + 1
a is shared_set of ["small", "ok"]
b is shared_set of ["big", big]
print of (json_encode of [a, shared_has of "small", b, shared_has of "big"])

With EIGS_HTTP_SHARED_MAX_BYTES=200 in the environment:

[null,true,null,false]

docs/BUILTINS.md says it ("Returns null if over byte cap"), so this is the contract as written and not a slip. It is still a call that did not do what was asked and told the caller nothing that differs from success (PRINCIPLES §2). The only way to find out is to read the key back. A server whose store is full goes on answering while every write is dropped.

shared_incr does the same in two places: over the cap, and on a key whose value is not a number (documented too). Both return null and change nothing, while its int64 overflow raises value.

Recommended

A write that is refused raises and changes nothing: value for the cap, with the builtin's name, the cap and the bytes the store would have held, as the int64 overflow of shared_incr raises today; and shared_incr on a value that is not a number raises too. Which kind that second raise has is decided here before the build.

Done when

  • The program above, with the cap at 200, raises value at the second shared_set, and after the raise small is still there and big is not.
  • A shared_set that replaces a value and would pass the cap raises, and the old value stays.
  • shared_incr over the cap raises value and changes nothing. shared_incr on a key that holds a string raises the kind decided here, and the string stays.
  • A route that catches none of these answers 500, as a route that raises does today.
  • docs/BUILTINS.md: the rows of shared_set and shared_incr and the paragraph on the cap say what is raised.
  • Shown once in the pull request: with the fix taken out, each row above is red.

— Claude DevBox

主要语言
C
星标
3
派生
7
平均合并
3 小时 28 分钟
30 天内合并 PR
270

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

从这里开始

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

InauguralSystems/EigenScript 的其他 Issue

查看 InauguralSystems/EigenScript 的全部 Issue

相似的 Issue

更多 C Issue

把新 issue 发到你的邮箱

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