When monitoring /var/log/journal/remote events are missed when two remote hosts send messages at the same time (updates)
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 35/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- linux, python
调研方向
Start with the journal.Reader polling example, especially seek_tail(), get_previous(), get_events(), iteration, and process(). Reproduce simultaneous writes from two clients and compare the event counter with journalctl -D /var/log/journal/remote/; done means explaining or correcting the missed-event behavior and confirming that all records are observed.
由索引模型根据 Issue 内容生成。
描述
Context
- 1 x log server (VM on Apple M2)
- 2 x log client (VM on Apple M2)
- Using systemd-journal-remote on server (http)
- Using systemd-journal-upload on clients (http)
Testing Method
We first cleanup the server with:
rm /var/log/journal/remote/*
On each client we run (side by side / simultaneously:
for x in {1..10000}; do echo "EVENT $x" | logger ; done
So we expect 20,000 records on the server, which we validate:
root@log-server:/home/ansible# journalctl -D /var/log/journal/remote/ --no-pager | grep -v Boot | wc -l
20000
I've tested this many times to confirm that the systemd-journal-remote/upload mechanism is OK.
The failing code
import select
from systemd import journal
j = journal.Reader(path="/var/log/journal/remote")
j.seek_tail()
j.get_previous() # prevent wrap around
p = select.poll()
p.register(j, j.get_events())
print("Starting....")
event_counter = 0
while p.poll():
for x in j:
event_counter += 1
if j.process() != journal.APPEND:
print("...WAITING....")
else:
print(f"Event counter: {event_counter}")
First of all, I'm not sure if this code is right. If I've made a glaring mistake, I apologise in advance for this report.
That said, I get correct results if I run my '10K log generator command' on one client at a time.
Event counter: 9915
Event counter: 9933
Event counter: 9945
Event counter: 9950
Event counter: 9987
Event counter: 10000
If I run the command at the same time on each client at once, I would expect 20K records, but it gets nowhere near that:
Event counter: 10228
Event counter: 10228
Event counter: 10228
Event counter: 10228
Event counter: 10228
Event counter: 10228
Event counter: 10228
In this example I'm missing almost half of all expected events. Yet I can confirm on the log server with the 'journalctl' command that there are actually 20K log records stored on the server.
Even if I test with just 1K events per client and run that simultaneously it's also clearly visible:
Event counter: 1096
Event counter: 1141
Event counter: 1215
Event counter: 1430
Happy to run any additional tests if that helps.
If I made a huge mistake, please let me know.
Update 1
I've been testing this issue on virtual machines on my mac.
I've also a few physical x86 micro pc's and the issue is the same.
Rate-limiting the logging with sleep .01 doesn't impact the result.
Question, is python-systemd built to handle remote logging from multiple clients through polling?
- 主要语言
- C
- 星标
- 522
- 派生
- 79
- PR 合并指标
- 30 天内没有已合并 PR
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
systemd/python-systemd 的其他 Issue
-
难度 3/5 1-2 天 新手友好度 48/100
systemd/python-systemd#177 · 1 条评论 · 1 个 reaction ·
-
难度 3/5 1-2 天 新手友好度 42/100
systemd/python-systemd#169 · 1 条评论 ·
-
难度 4/5 3-5 天 新手友好度 48/100
systemd/python-systemd#167 · 19 条评论 ·
-
难度 5/5 一周以上 新手友好度 35/100
systemd/python-systemd#152 · 1 条评论 · 13 个 reaction ·
-
难度 4/5 3-5 天 新手友好度 45/100
systemd/python-systemd#146 · 2 条评论 ·
查看 systemd/python-systemd 的全部 Issue
相似的 Issue
-
Status: Waiting triage Type: Bug
难度 2/5 1-3 小时 新手友好度 84/100
nanoframework/Home#1857 ·
-
难度 2/5 1-3 小时 新手友好度 68/100
-
难度 1/5 1 小时以内 新手友好度 92/100
libsdl-org/SDL#16372 ·
-
难度 2/5 1-3 小时 新手友好度 84/100
corazawaf/coraza-nginx#140 ·
-
难度 2/5 1-3 小时 新手友好度 78/100