我已经编写了一个java程序来对我的cassandra数据库执行upsert操作,它由一个具有多个列表的表组成,我正在使用java代码尝试同时写入多个这样的列表假设一次写入10个,但是,当我查看我的cassandra表时,列表中的值并没有以同步的方式存储,一些值从原始位置切换位置,尽管每个值的时间戳都是正确的,但不知何故列表没有以正确的顺序表示。共享文件和示例代码,这将有助于识别问题。
String newInsertQuery1 = "UPDATE events.generated_event SET attributes = ['100'] + attributes, channels = ['100'] + channels, " + "event_types = ['100'] + event_types, ip = ['100'] + ip, library_info = ['100'] + library_info, property_ids = ['100'] + property_ids," + "texts = ['100'] + texts, user_agent = ['100'] + user_agent WHERE profile_id = '1111' AND project_id = '5bbc83f4bf52016962b695da' AND bucket_id = 1555977600000";
String newInsertQuery2 = "UPDATE events.generated_event SET attributes = ['300'] + attributes, channels = ['300'] + channels, " + "event_types = ['300'] + event_types, ip = ['300'] + ip, library_info = ['300'] + library_info, property_ids = ['300'] + property_ids," + "texts = ['300'] + texts, user_agent = ['300'] + user_agent WHERE profile_id = '1111' AND project_id = '5bbc83f4bf52016962b695da' AND bucket_id = 1555977600000";
String newInsertQuery3 = "UPDATE events.generated_event SET attributes = ['400'] + attributes, channels = ['400'] + channels, " + "event_types = ['400'] + event_types, ip = ['400'] + ip, library_info = ['400'] + library_info, property_ids = ['400'] + property_ids," + "texts = ['400'] + texts, user_agent = ['400'] + user_agent WHERE profile_id = '1111' AND project_id = '5bbc83f4bf52016962b695da' AND bucket_id = 1555977600000";
类似地,查询4、5、6、7。
我让许多线程同时运行,每个线程执行一个查询。
扩展结果:
profile_id | 1111
project_id | 5bbc83f4bf52016962b695da
bucket_id | 1555977600000
anonymous_id | 150698a7-5d02-f634-3c8d-4d7bf615f13e
attributes | ['300', '700', '400', '600', '500', '800', '00']
channels | ['300', '700', '400', '600', '500', '800', '00']
event_types | ['300', '700', '400', '600', '500', '800', '00']
ip | ['300', '700', '400', '600', '500', '800', '00']
library_info | ['300', '700', '400', '600', '500', '800', '00']
property_ids | ['300', '700', '400', '600', '500', '800', '00']
texts | ['300', '700', '400', '600', '500', '800', '00']
timestamps | null
user_agent | ['300', '700', '400', '600', '500', '800', '00']
实际结果:
profile_id | 1111
project_id | 5bbc83f4bf52016962b695da
bucket_id | 1555977600000
anonymous_id | 150698a7-5d02-f634-3c8d-4d7bf615f13e
attributes | ['300', '700', '500', '400', '800', '600', '00']
channels | ['300', '700', '400', '600', '800', '500', '00']
event_types | ['300', '700', '400', '600', '500', '800', '00']
ip | ['300', '700', '400', '600', '500', '800', '00']
library_info | ['300', '700', '400', '600', '500', '800', '00']
property_ids | ['300', '700', '400', '600', '500', '800', '00']
texts | ['300', '700', '400', '600', '800', '500', '00']
timestamps | null
user_agent | ['300', '700', '400', '600', '500', '800', '00']
所附的图像由sstabledump命令的输出组成,如您所见,每行中的tstamp值(比如800)是相同的,但当我对此表执行读取时,打印给我的值不会被排序,它们的打印顺序与sstabledump中写入的顺序相同
1条答案
按热度按时间n9vozmp41#
如果在同一行上使用由不同线程发出的多个查询,则不能保证更新将按特定顺序执行。