Hello,
Did the expected object type for tokens change from bytearray (as blobs) to something else?
I am running development code that was working fine earlier this month. I changed operating systems (arch to gentoo), reinstalled cassandra and the cassandra-driver, and I'm getting an odd error now. I tried rolling back to cassandra 2.0.9 and cassandra-driver-2.0.10 and 2.0.2 (among others) - although my code was running fine on cassandra-2.1.2 and cassandra-driver-2.1.2.
Here is the error:
[pid: 16478|app: 0|req: 1/1] 127.0.0.1 () {50 vars in 886 bytes} [Mon Feb 2 05:41:09 2015] POST / db_show_bounded_items.json => generated 0 bytes in 6 msecs (HTTP/1.1 500) 0 headers in 0 bytes (0 switches on core 0)
lngdif = 1.816864013671875
SELECT title, ranking, itemid FROM events.items WHERE token(muid) >= ? AND token(muid) <= ? LIMIT 30;
['62c13d000000308c8450000000000000', '62c13d000000308c8850000000000000']
Traceback (most recent call last):
File "/var/env/tacle/lib64/python3.4/site-packages/cassandra/query.py", line 460, in bind
self.values.append(col_type.serialize(value))
struct.error: required argument is not an integer
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/var/env/tacle/lib64/python3.4/site-packages/pyramid-1.5.2-py3.4.egg/pyramid/router.py", line 242, in __call__
response = self.invoke_subrequest(request, use_tweens=True)
File "/var/env/tacle/lib64/python3.4/site-packages/pyramid-1.5.2-py3.4.egg/pyramid/router.py", line 217, in invoke_subrequest
response = handle_request(request)
File "/var/env/tacle/lib64/python3.4/site-packages/pyramid-1.5.2-py3.4.egg/pyramid/tweens.py", line 21, in excview_tween
response = handler(request)
File "/var/env/tacle/lib64/python3.4/site-packages/pyramid-1.5.2-py3.4.egg/pyramid/router.py", line 163, in handle_request
response = view_callable(context, request)
File "/var/env/tacle/lib64/python3.4/site-packages/pyramid-1.5.2-py3.4.egg/pyramid/config/views.py", line 355, in rendered_view
result = view(context, request)
File "/var/env/tacle/lib64/python3.4/site-packages/pyramid-1.5.2-py3.4.egg/pyramid/config/views.py", line 491, in _class_view
response = getattr(inst, attr)()
File "/var/www/tacle/tacboard/db_views.py", line 102, in db_show_bounded_items
querycols=querycols))
File "/var/www/tacle/items/tac.py", line 352, in query_muid_list
uuid.UUID(muid_pair[1]),
File "/var/env/tacle/lib64/python3.4/site-packages/cassandra/query.py", line 361, in bind
return BoundStatement(self).bind(values)
File "/var/env/tacle/lib64/python3.4/site-packages/cassandra/query.py", line 468, in bind
raise TypeError(message)
TypeError: Received an argument of invalid type for column "partition key token". Expected: <class 'cassandra.cqltypes.LongType'>, Got: <class 'bytearray'>
[pid: 16478|app: 0|req: 2/2] 127.0.0.1 () {50 vars in 886 bytes} [Mon Feb 2 05:52:20 2015] POST /db_show_bounded_items.json => generated 0 bytes in 4 msecs (HTTP/1.1 500) 0 headers in 0 bytes (0 switches on core 0)
Here is the relevant code (sorry if the formatting ends up messy):
if type(muid_list) is list:
st = ("SELECT {columns} FROM {keyspace}.{table} "
"WHERE token(muid) >= ? AND token(muid) <= ? "
"LIMIT {limit};").format(columns=", ".join(querycols),
keyspace=self.keyspace,
table=table,
limit=limit)
bs = CaSession.session.prepare(st)
futures = []
print(st) <-------- this is part of the printout
for muid_pair in muid_list:
print(str(muid_pair)) <-------- these are the two hex numbers
futures.append(
CaSession.session.execute_async(
bs.bind((
bytearray.fromhex(muid_pair[0]), <------- error occurs here
bytearray.fromhex(muid_pair[1]),
#int(muid_pair[0], 16),
#int(muid_pair[1], 16),
))))
However, casting to an integer doesn't work either.. looking at metadata.py, it looks like the driver is expecting a 64 bit int (juding by LongType using 64_pack and 64_unpack). This doesn't make sense, since Cassandra tokens are 128 bits.
What I really don't understand is why downgrading isn't working - perhaps bytearrays were only used for tokens for one version?
Thanks,