Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
374 views
in Technique[技术] by (71.8m points)

datastax - Cassandra update query didn't change data and didn't throw an error

Hello I am facing a problem when I am trying to execute a really simple update query in cqlsh

update "Table" set "token"='111-222-333-444' where uid='123' and "key"='somekey';

It didn't throw any error, but the value of the token is still the same. However, if I try the same query for some other field it works just fine:

update "Table" set "otherfield"='value' where uid='123' and "key"='somekey';

Any ideas why Cassandra can prevent updates for some fields?

question from:https://stackoverflow.com/questions/65838183/cassandra-update-query-didnt-change-data-and-didnt-throw-an-error

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Most probably the entry was inserted by client with incorrect clocks, or something like. The data in Cassandra are "versioned" by write time that could be even in the future (depending on use case). And when reading, Cassandra compares the write time of all versions of the specified column (there could be multiple versions in the data files on the disk), and selects one with highest write time.

You need to check the write time of that column value (use the writetime function) and compare with your current time:

select writetime(token) from Table where uid='123' and "key"='somekey';

the resulting value is in the microseconds. You can remove last 3 digits, and use something like this site to convert it into human-understandable time.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...