Commit 33d974b
committed
fix(checkpoint-redis): resolve key generation inconsistency in shallow savers
Fix incomplete cleanup of blobs and writes in ShallowRedisSaver and AsyncShallowRedisSaver
due to inconsistent key generation between base class and shallow cleanup patterns.
The base class uses storage-safe transformations (to_storage_safe_id/to_storage_safe_str)
which convert empty checkpoint_ns to "__empty__", while shallow cleanup patterns used
raw empty strings, causing cleanup operations to miss actual keys.
Changes:
- Update _make_shallow_redis_checkpoint_blob_key_pattern to use to_storage_safe_id/to_storage_safe_str
- Update _make_shallow_redis_checkpoint_writes_key_pattern to use same transformations
- Apply fixes to both sync (shallow.py) and async (ashallow.py) implementations
- Add comprehensive tests to verify cleanup behavior and key generation consistency
Fixes prevent memory leaks where old blob versions and writes accumulated instead
of being properly cleaned up during checkpoint operations.1 parent f2e3c32 commit 33d974b
File tree
6 files changed
+336
-17
lines changed- langgraph/checkpoint/redis
- tests
6 files changed
+336
-17
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
221 | 221 | | |
222 | 222 | | |
223 | 223 | | |
| 224 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | | - | |
10 | | - | |
11 | | - | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| 16 | + | |
15 | 17 | | |
16 | | - | |
17 | | - | |
| 18 | + | |
| 19 | + | |
18 | 20 | | |
19 | 21 | | |
20 | | - | |
| 22 | + | |
21 | 23 | | |
22 | 24 | | |
23 | 25 | | |
| 26 | + | |
24 | 27 | | |
25 | | - | |
26 | 28 | | |
| 29 | + | |
27 | 30 | | |
28 | 31 | | |
29 | 32 | | |
30 | 33 | | |
31 | 34 | | |
| 35 | + | |
32 | 36 | | |
33 | 37 | | |
34 | 38 | | |
| |||
38 | 42 | | |
39 | 43 | | |
40 | 44 | | |
| 45 | + | |
41 | 46 | | |
42 | | - | |
| 47 | + | |
43 | 48 | | |
44 | 49 | | |
45 | 50 | | |
46 | 51 | | |
| 52 | + | |
47 | 53 | | |
48 | 54 | | |
49 | 55 | | |
| |||
63 | 69 | | |
64 | 70 | | |
65 | 71 | | |
| 72 | + | |
66 | 73 | | |
67 | 74 | | |
68 | 75 | | |
69 | 76 | | |
70 | 77 | | |
71 | 78 | | |
72 | 79 | | |
| 80 | + | |
73 | 81 | | |
| 82 | + | |
74 | 83 | | |
75 | 84 | | |
76 | 85 | | |
| |||
79 | 88 | | |
80 | 89 | | |
81 | 90 | | |
| 91 | + | |
82 | 92 | | |
83 | 93 | | |
84 | 94 | | |
85 | | - | |
| 95 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1003 | 1003 | | |
1004 | 1004 | | |
1005 | 1005 | | |
1006 | | - | |
| 1006 | + | |
1007 | 1007 | | |
1008 | 1008 | | |
1009 | 1009 | | |
| |||
1013 | 1013 | | |
1014 | 1014 | | |
1015 | 1015 | | |
1016 | | - | |
| 1016 | + | |
1017 | 1017 | | |
1018 | 1018 | | |
1019 | 1019 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
38 | 42 | | |
39 | 43 | | |
40 | 44 | | |
| |||
812 | 816 | | |
813 | 817 | | |
814 | 818 | | |
815 | | - | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
816 | 826 | | |
817 | 827 | | |
818 | 828 | | |
| |||
823 | 833 | | |
824 | 834 | | |
825 | 835 | | |
826 | | - | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
827 | 841 | | |
828 | 842 | | |
829 | 843 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
30 | 34 | | |
31 | 35 | | |
32 | 36 | | |
| |||
713 | 717 | | |
714 | 718 | | |
715 | 719 | | |
716 | | - | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
717 | 727 | | |
718 | 728 | | |
719 | 729 | | |
| |||
724 | 734 | | |
725 | 735 | | |
726 | 736 | | |
727 | | - | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
728 | 742 | | |
729 | 743 | | |
730 | 744 | | |
0 commit comments