为什么 Cassandra 使用字节键(使用 Lazyboy)会表现得很奇怪?
我编写了一个测试程序来测试 Cassandra,但在读取数据时遇到了问题。看来卡桑德拉有时会把一把钥匙换成另一把钥匙。
这是我的测试程序:(
from lazyboy import *
from lazyboy.key import Key
import uuid
import random
class TestItemKey(Key):
def __init__(self, key=None):
Key.__init__(self, "TestMX", "TestCF", key)
class TestItem(record.Record):
def __init__(self, *args, **kwargs):
record.Record.__init__(self, *args, **kwargs)
self.key = TestItemKey(uuid.uuid1().bytes)
connection.add_pool('TestMX', ['localhost:9160'])
t1 = TestItem({'test':'foo'})
t1.key = TestItemKey(uuid.UUID('3cead15a-a54e-11df-87a2-000c298d2724').bytes)
t2 = TestItem({'test':'bar'})
t2.key = TestItemKey(uuid.UUID('3cebc15a-a54e-11df-87a2-000c298d2724').bytes)
t1.save()
t2.save()
print TestItem().load(t1.key.clone())
print TestItem().load(t2.key.clone())
所选的 UUID 是导致问题的示例)
以下是此脚本的输出:
root@ubuntu:/mnt/hgfs/TestMX# python test.py
TestItem: {'test': 'foo'}
TestItem: {'test': 'foo'}
而不是预期结果:
root@ubuntu:/mnt/hgfs/TestMX# python test.py
TestItem: {'test': 'foo'}
TestItem: {'test': 'bar'}
请注意,该脚本通常与其他随机选择的 UUID 配合使用效果很好,但有时则不然...
I wrote a test program for testing Cassandra, and I had problems reading data. Seems like Cassandra sometimes takes one key for another.
Here is my test program :
from lazyboy import *
from lazyboy.key import Key
import uuid
import random
class TestItemKey(Key):
def __init__(self, key=None):
Key.__init__(self, "TestMX", "TestCF", key)
class TestItem(record.Record):
def __init__(self, *args, **kwargs):
record.Record.__init__(self, *args, **kwargs)
self.key = TestItemKey(uuid.uuid1().bytes)
connection.add_pool('TestMX', ['localhost:9160'])
t1 = TestItem({'test':'foo'})
t1.key = TestItemKey(uuid.UUID('3cead15a-a54e-11df-87a2-000c298d2724').bytes)
t2 = TestItem({'test':'bar'})
t2.key = TestItemKey(uuid.UUID('3cebc15a-a54e-11df-87a2-000c298d2724').bytes)
t1.save()
t2.save()
print TestItem().load(t1.key.clone())
print TestItem().load(t2.key.clone())
(The chosen UUIDs are an example of the ones causing problems)
Here is the output of this script :
root@ubuntu:/mnt/hgfs/TestMX# python test.py
TestItem: {'test': 'foo'}
TestItem: {'test': 'foo'}
Instead of the expected result :
root@ubuntu:/mnt/hgfs/TestMX# python test.py
TestItem: {'test': 'foo'}
TestItem: {'test': 'bar'}
Note that the script usually works great with other randomely-chosen UUIDs, but sometimes not...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
听起来很像您正在点击 https://issues.apache.org/jira/ browser/CASSANDRA-1235 已在 0.6 分支中修复,并将在下一个稳定版本 0.6.5 中发布。
Sounds a lot like you're hitting https://issues.apache.org/jira/browse/CASSANDRA-1235 which is fixed in the 0.6 branch and will be in 0.6.5, the next stable release.