Skip to content

Commit bcb01f2

Browse files
committed
kvs: correct code logic about what is an append
Problem: In PR #2547, a fix was added into the KVS to deal with duplicate appends to a KVS entry. However, a corner case was left in the code. When an append is done to a KVS entry that does not exist, the append is treated like a normal insertion. This corner case should also be counted as an "append". Otherwise, duplicate appends could happen at the beginning of a KVS entry when it is created. Solution: Set the append flag to true when a KVS entry does not exist and the append is treated like an insert. Fixes #6207
1 parent c9296ea commit bcb01f2

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/modules/kvs/kvstxn.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,10 @@ static int kvstxn_append (kvstxn_t *kt, json_t *dirent,
495495
/* entry not found, treat like normal insertion */
496496
if (treeobj_insert_entry (dir, final_name, dirent) < 0)
497497
return -1;
498+
/* N.B. although this is an "insert", we still treat this as
499+
* an "append". If we don't, the "append" could be issued
500+
* twice, leading to duplicated data. See issue #6207. */
501+
(*append) = true;
498502
}
499503
else if (treeobj_is_valref (entry)) {
500504
char ref[BLOBREF_MAX_STRING_SIZE];

0 commit comments

Comments
 (0)