Skip to content

Commit

Permalink
kvs: correct code logic about what is an append
Browse files Browse the repository at this point in the history
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
  • Loading branch information
chu11 committed Aug 10, 2024
1 parent c9296ea commit bcb01f2
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/modules/kvs/kvstxn.c
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,10 @@ static int kvstxn_append (kvstxn_t *kt, json_t *dirent,
/* entry not found, treat like normal insertion */
if (treeobj_insert_entry (dir, final_name, dirent) < 0)
return -1;
/* N.B. although this is an "insert", we still treat this as
* an "append". If we don't, the "append" could be issued
* twice, leading to duplicated data. See issue #6207. */
(*append) = true;
}
else if (treeobj_is_valref (entry)) {
char ref[BLOBREF_MAX_STRING_SIZE];
Expand Down

0 comments on commit bcb01f2

Please sign in to comment.