Skip to content

只有一个line清空line后会清空整个topic #7

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

Open
w22gb8 opened this issue May 20, 2015 · 4 comments
Open

只有一个line清空line后会清空整个topic #7

w22gb8 opened this issue May 20, 2015 · 4 comments

Comments

@w22gb8
Copy link

w22gb8 commented May 20, 2015

清空一个line后一会整个topic都清空了:
127.0.0.1:8800> add test
OK
127.0.0.1:8800> add test/a 10s
OK
127.0.0.1:8800> set test a
OK
127.0.0.1:8800> set test b
OK
127.0.0.1:8800> empty test/a
OK
127.0.0.1:8800> info test
name:test
head:0
tail:2
count:2 此时正常

name:test/a
recycle:10s
head:2
ihead:2
tail:2
count:0
127.0.0.1:8800> info test 等待一会再执行
name:test
head:2
tail:2
count:0 此时就空了

name:test/a
recycle:10s
head:2
ihead:2
tail:2
count:0

@buaazp
Copy link
Owner

buaazp commented May 21, 2015

这个是正确的,我简单解释一下:

当你的topic里只有一个line时,先set进来2条消息,这时topic和line里都有消息;然后你清空了line,如果还有别的line存在的话,topic里的消息还可能被别的line拿走,所以topic不应该清空;但是因为只有一条line,这些已经清空的(还包括被确认的)消息了,一直放在topic里的话会导致存储量无限增加,必须被垃圾回收。

所以uq里的设计思路是,如果已经被确认的消息(指的是已经没用了的消息),后台有一个定时任务在清理它们。也就是说,如果你在topic运行了一段时间之后又要新增加一条line,它只能拿到那一时刻还存在于topic中的有用消息,再往前的那些已经被别的line消费掉的消息,就拿不到了。

主要是出于存储量的考虑,欢迎探讨。

@w22gb8
Copy link
Author

w22gb8 commented May 21, 2015

增加手动从topic内删除消息也许更好一点,有的会需要保存消息久点或后续新增line处理之前累积的消息。
一家之言,不必认真,谢谢提供这么好的工具。

@buaazp
Copy link
Owner

buaazp commented May 21, 2015

搞成根据用户场景可配置也是可以的,我再考虑考虑。

@hongbing
Copy link

可以借鉴zookeeper设置ephemeral节点的思想。
设置常规topic和非常规topic,非常规的就是指即使topic中所有line中的元素被确认后,不会立即被删除,还可以存储一段时间。这个时间的长短依赖于使用方针对自己业务的需求而定。

或者直接针对topic设定一个过期时间。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants