A racing object sync can end up with multiple calls to cb.complete() which
in turn will end up with this method getting called multiple times. We can't
claim the bufferlist again, and will just clobber first_chunk.
Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
int RGWPutObjProcessor_Atomic::complete_writing_data()
{
if (!data_ofs && !immutable_head()) {
- first_chunk.claim(pending_data_bl);
+ /* only claim if pending_data_bl() is not empty. This is needed because we might be called twice
+ * (e.g., when a retry due to race happens). So a second call to first_chunk.claim() would
+ * clobber first_chunk
+ */
+ if (pending_data_bl.length() > 0) {
+ first_chunk.claim(pending_data_bl);
+ }
obj_len = (uint64_t)first_chunk.length();
}
if (pending_data_bl.length()) {