Commit ac7db73
committed
change: fix update_config_cache crash when 'after' entry is missing
When sysrepo sends a batch of changes where a ChangeDeleted removes a
list entry and a subsequent ChangeCreated references that same entry in
its 'after' parameter (to specify insertion order), xpath_set() raises a
ValueError because the referenced entry no longer exists in the cache.
This happens in practice when list entries are rapidly created and
deleted (e.g. coredump files appearing during repeated service crashes).
The ValueError propagates up and kills the sysrepo subscription callback,
which in the case of the alarm manager means no further alarms are
processed for the rest of the session.
Fix this by catching the ValueError and retrying without the 'after'
parameter, which appends the new entry at the end of the list. The entry
is still created, only the insertion order is lost, which is an
acceptable trade-off compared to crashing the entire callback.
The fix is done in sysrepo-python (the caller that knows the context)
rather than in libyang-python (which is correct to be strict about
invalid 'after' references).
Add a dedicated unit test for update_config_cache covering both the
normal case (after entry exists) and the fallback case (after entry
was deleted).
Acked-by: Jean-Sébastien Bevilacqua <jean-sebastien.bevilacqua@6wind.com>1 parent c5fbdaf commit ac7db73
2 files changed
Lines changed: 62 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
206 | 206 | | |
207 | 207 | | |
208 | 208 | | |
209 | | - | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
210 | 215 | | |
211 | 216 | | |
212 | 217 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
0 commit comments