我已经编写了一个Java程序来对我的cassandra db执行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']
答案 0 :(得分:0)
如果您在不同线程发出的同一行上使用多个查询,则不能保证更新将以特定顺序执行。