Are HBase Batch Operations Atomic?

僤鯓⒐⒋嵵緔 提交于 2019-12-12 02:49:35

问题


// Create a list of Puts, and save in HBase via HTable's batch method
HTable table = new HTable(HBaseConfiguration.create(), 'table_name');
List<Row> actions = new ArrayList<Row>();
actions.add(put1); //rowkey = 'abc'
actions.add(put2); //rowkey = 'def'
actions.add(put3); //rowkey = 'ghi'
Object[] results = table.batch(actions);

Is it possible that this snippit could result in at least one, but not all, of the puts failing to to save to HBase? In other words, is batch guarenteed to happen atomically, where either all the puts are saved, or none of them all?

If batch cannot guarantee this, how can we identify which of the puts succeeded and which failed? Or, can we at least identify that something failed, which would tell us to go delete all the rows we tried to save in order to roll them back?

When I cast the results to Result and print them out, it returns keyvalues=NONE, but I can see that my puts succeeded.


回答1:


From hbase client api docs :

public void batch(List<? extends Row> actions, Object[] results)

actions list of Get, Put, Delete, Increment, Append

objectsresults Empty Object[], same size as actions. Provides access to partial results, in case an exception is thrown. A null in the result array means that the call for that action failed, even after retries

You can check if every result is success as you sad in your question, other than batch operations are not transactional in hbase by design, row mutating operations may happen different regions servers, thus different wal files, so it can not be transactional, there are some opensource project trying to make this happen as checking results and rolling back successful ones too.



来源:https://stackoverflow.com/questions/35144537/are-hbase-batch-operations-atomic

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!