Commit e426a6f
authored
fix: correct per-type memory accounting when object type changes in AutoUpdater (#7142)
AutoUpdater::Run() applied the full delta (new_size - orig_size) to the
current object type. When AddOrUpdate replaces a value with a different
type (e.g., SORT STORE overwrites a SET with a LIST), the original bytes
were tracked under the old type but the delta was subtracted from the new
type's counter — which never had those bytes — causing an underflow crash.
- Add orig_obj_type to AutoUpdater::Fields, captured at construction time
- In Run(): when type changed, separately subtract orig_size from old type
and add current_size to new type, instead of applying a signed delta to
the new type
- In ReduceHeapUsage(): use orig_obj_type for correct accounting, then sync
it to current type so subsequent Run() sees consistent state
- In AddTypeMemoryUsage(): crash with FATAL in debug builds on underflow
(was ERROR) and log the per-type counter value instead of obj_memory_usage
Signed-off-by: Roman Gershman <roman@dragonflydb.io>1 parent 975b6e0 commit e426a6f
3 files changed
Lines changed: 29 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
473 | 473 | | |
474 | 474 | | |
475 | 475 | | |
476 | | - | |
| 476 | + | |
477 | 477 | | |
478 | | - | |
| 478 | + | |
| 479 | + | |
479 | 480 | | |
480 | 481 | | |
481 | 482 | | |
| |||
490 | 491 | | |
491 | 492 | | |
492 | 493 | | |
493 | | - | |
494 | | - | |
495 | | - | |
496 | | - | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
497 | 510 | | |
498 | 511 | | |
499 | 512 | | |
| |||
508 | 521 | | |
509 | 522 | | |
510 | 523 | | |
511 | | - | |
| 524 | + | |
| 525 | + | |
512 | 526 | | |
513 | 527 | | |
514 | 528 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
175 | 175 | | |
176 | 176 | | |
177 | 177 | | |
| 178 | + | |
178 | 179 | | |
179 | 180 | | |
180 | 181 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
30 | | - | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
31 | 36 | | |
32 | 37 | | |
33 | 38 | | |
| |||
0 commit comments