Commit b47a630
authored
Byte size replication cache per shard (#7243)
<!-- Describe what has changed in this PR -->
**What changed?**
Enforced per-shard replication cache limits by item count and total byte
size.
Added ByteSize() implementations for ReplicationTask and all referenced
sub-types to enable accurate memory accounting.
Added util test methods to verify ByteSize implementation and ensure
that additions to structs using ByteSize will have ByteSize implemented
and implemented correctly.
<!-- Tell your future self why have you made these changes -->
**Why?**
Replication task sizes vary widely—from really small to hundreds of KiB.
A count-only limit lets a few large tasks blow past the intended memory
budget, leading to potential OOM in the history service. Adding a
byte-size bound (with accurate ByteSize() accounting) keeps each shard
within a predictable memory maximum usage.
<!-- How have you verified this change? Tested locally? Added a unit
test? Checked in staging env? -->
**How did you test it?**
Unit tests and deployment tests.
<!-- Assuming the worst case, what can be broken when deploying this
change to production? -->
**Potential risks**
Replication cache continues to be disabled by default. Enabling it
without a max size value or a value that is too large may cause memory
issues.
<!-- Is it notable for release? e.g. schema updates, configuration or
data migration required? If so, please mention it, and also update
CHANGELOG.md -->
**Release notes**
Introduce per-shard replication cache limits by count and total bytes
(opt-in). Implement ByteSize() across ReplicationTask and nested types
for accurate memory accounting, reducing risk of memory spikes in the
history service.
<!-- Is there any documentation updates should be made for config,
https://cadenceworkflow.io/docs/operation-guide/setup/ ? If so, please
open an PR in https://github.com/cadence-workflow/cadence-docs -->
**Documentation Changes**
---------
Signed-off-by: fimanishi <[email protected]>1 parent 72d3984 commit b47a630
File tree
14 files changed
+730
-62
lines changed- cmd/server
- common
- archiver/gcloud
- dynamicconfig/dynamicproperties
- types
- service/history
- config
- replication
14 files changed
+730
-62
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
| 82 | + | |
82 | 83 | | |
83 | 84 | | |
84 | 85 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| 76 | + | |
76 | 77 | | |
77 | 78 | | |
78 | 79 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1091 | 1091 | | |
1092 | 1092 | | |
1093 | 1093 | | |
1094 | | - | |
| 1094 | + | |
1095 | 1095 | | |
1096 | 1096 | | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
1097 | 1103 | | |
1098 | 1104 | | |
1099 | 1105 | | |
| |||
3693 | 3699 | | |
3694 | 3700 | | |
3695 | 3701 | | |
| 3702 | + | |
| 3703 | + | |
| 3704 | + | |
| 3705 | + | |
| 3706 | + | |
3696 | 3707 | | |
3697 | 3708 | | |
3698 | 3709 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
24 | 27 | | |
25 | 28 | | |
26 | 29 | | |
| |||
317 | 320 | | |
318 | 321 | | |
319 | 322 | | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
320 | 331 | | |
321 | 332 | | |
322 | 333 | | |
| |||
356 | 367 | | |
357 | 368 | | |
358 | 369 | | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
359 | 383 | | |
360 | 384 | | |
361 | 385 | | |
| |||
422 | 446 | | |
423 | 447 | | |
424 | 448 | | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
425 | 461 | | |
426 | 462 | | |
427 | 463 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
99 | 100 | | |
100 | 101 | | |
101 | 102 | | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
102 | 111 | | |
103 | 112 | | |
104 | 113 | | |
| |||
195 | 204 | | |
196 | 205 | | |
197 | 206 | | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
198 | 223 | | |
199 | 224 | | |
200 | 225 | | |
| |||
226 | 251 | | |
227 | 252 | | |
228 | 253 | | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
229 | 269 | | |
230 | 270 | | |
231 | 271 | | |
| |||
399 | 439 | | |
400 | 440 | | |
401 | 441 | | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
402 | 464 | | |
403 | 465 | | |
404 | 466 | | |
| |||
656 | 718 | | |
657 | 719 | | |
658 | 720 | | |
659 | | - | |
| 721 | + | |
660 | 722 | | |
661 | 723 | | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
662 | 727 | | |
663 | 728 | | |
664 | 729 | | |
| |||
727 | 792 | | |
728 | 793 | | |
729 | 794 | | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
730 | 815 | | |
731 | 816 | | |
732 | 817 | | |
| |||
898 | 983 | | |
899 | 984 | | |
900 | 985 | | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
901 | 994 | | |
902 | 995 | | |
903 | 996 | | |
| |||
1028 | 1121 | | |
1029 | 1122 | | |
1030 | 1123 | | |
| 1124 | + | |
| 1125 | + | |
| 1126 | + | |
| 1127 | + | |
| 1128 | + | |
| 1129 | + | |
| 1130 | + | |
| 1131 | + | |
| 1132 | + | |
| 1133 | + | |
| 1134 | + | |
| 1135 | + | |
| 1136 | + | |
| 1137 | + | |
| 1138 | + | |
| 1139 | + | |
| 1140 | + | |
| 1141 | + | |
| 1142 | + | |
| 1143 | + | |
| 1144 | + | |
| 1145 | + | |
| 1146 | + | |
| 1147 | + | |
| 1148 | + | |
| 1149 | + | |
| 1150 | + | |
| 1151 | + | |
| 1152 | + | |
| 1153 | + | |
| 1154 | + | |
1031 | 1155 | | |
1032 | 1156 | | |
1033 | 1157 | | |
| |||
1047 | 1171 | | |
1048 | 1172 | | |
1049 | 1173 | | |
| 1174 | + | |
| 1175 | + | |
| 1176 | + | |
| 1177 | + | |
| 1178 | + | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1227 | 1227 | | |
1228 | 1228 | | |
1229 | 1229 | | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
0 commit comments