Commit cee425f
committed
PS-10113 [8.4] Server crashes if JS routine tries to allocate more than internal heap memory limit
https://perconadev.atlassian.net/browse/PS-10113
Attempt to allocate more than js_lang.max_mem_size * 4 bytes of memory
on JS heap in one go caused server crash.
The problem occurred because such allocation exceeded V8 memory limit,
which was set by our JS language component to be 4x from the memory
limit specified by used through js_lang.max_mem_size variable.
The idea was that we should be able to detect exceeding max_mem_size
limit well before reaching V8 memory limit. It worked OK in case of
small allocations, but failed in case when the problem was caused
by single huge allocation.
V8 is not good at handling OOM situations gracefully and simply aborts
process if allocation is about to exceed its memory limit and extra GC
doesn't help.
This patch tries to alleviate the problem by not setting V8 memory limit
explicitly and relying on its generous default instead (typically > 1Gb).
As result only really huge allocation attempts should be affected.
The old behavior is still can be achieved by setting newly introduced
js_lang.max_mem_size_hard_limit_factor system variable to non-0 value.
In this case JS language component will set V8 memory limit to
max_mem_size * max_mem_size_hard_limit_factor bytes, and one should be
ready to tolerate process aborts if this limit is exceeded. To reduce
chance of misuse changing of this new variable requires server restart.1 parent 29998d6 commit cee425f
File tree
5 files changed
+209
-43
lines changed- components/js_lang
- mysql-test/suite/component_js_lang
- r
- t
5 files changed
+209
-43
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
116 | | - | |
| 116 | + | |
117 | 117 | | |
118 | | - | |
| 118 | + | |
119 | 119 | | |
| 120 | + | |
120 | 121 | | |
121 | 122 | | |
122 | 123 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
301 | 301 | | |
302 | 302 | | |
303 | 303 | | |
304 | | - | |
305 | | - | |
306 | | - | |
307 | | - | |
308 | | - | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
309 | 308 | | |
310 | | - | |
311 | | - | |
312 | | - | |
313 | | - | |
314 | | - | |
315 | | - | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
316 | 312 | | |
317 | 313 | | |
318 | 314 | | |
319 | 315 | | |
320 | 316 | | |
321 | | - | |
322 | | - | |
323 | | - | |
324 | | - | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
325 | 322 | | |
326 | 323 | | |
327 | 324 | | |
| |||
573 | 570 | | |
574 | 571 | | |
575 | 572 | | |
| 573 | + | |
576 | 574 | | |
577 | 575 | | |
578 | 576 | | |
579 | | - | |
| 577 | + | |
580 | 578 | | |
581 | | - | |
582 | | - | |
583 | | - | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
584 | 582 | | |
585 | 583 | | |
586 | 584 | | |
587 | | - | |
| 585 | + | |
| 586 | + | |
588 | 587 | | |
589 | 588 | | |
590 | 589 | | |
| |||
593 | 592 | | |
594 | 593 | | |
595 | 594 | | |
596 | | - | |
| 595 | + | |
597 | 596 | | |
598 | 597 | | |
599 | 598 | | |
| |||
605 | 604 | | |
606 | 605 | | |
607 | 606 | | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
608 | 635 | | |
609 | 636 | | |
610 | 637 | | |
611 | 638 | | |
612 | 639 | | |
613 | | - | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
614 | 643 | | |
615 | 644 | | |
616 | 645 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
393 | 393 | | |
394 | 394 | | |
395 | 395 | | |
396 | | - | |
| 396 | + | |
397 | 397 | | |
398 | 398 | | |
399 | 399 | | |
400 | 400 | | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
401 | 411 | | |
402 | 412 | | |
403 | 413 | | |
| |||
Lines changed: 60 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | | - | |
12 | | - | |
| 10 | + | |
| 11 | + | |
13 | 12 | | |
14 | 13 | | |
15 | 14 | | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
16 | 19 | | |
17 | | - | |
18 | | - | |
19 | | - | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
20 | 23 | | |
21 | 24 | | |
22 | 25 | | |
23 | 26 | | |
24 | | - | |
25 | | - | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| |||
35 | 36 | | |
36 | 37 | | |
37 | 38 | | |
38 | | - | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
39 | 46 | | |
40 | 47 | | |
41 | 48 | | |
| |||
290 | 297 | | |
291 | 298 | | |
292 | 299 | | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
293 | 343 | | |
| 344 | + | |
294 | 345 | | |
295 | 346 | | |
296 | 347 | | |
| |||
Lines changed: 84 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
6 | 10 | | |
7 | 11 | | |
8 | 12 | | |
| |||
15 | 19 | | |
16 | 20 | | |
17 | 21 | | |
18 | | - | |
19 | | - | |
20 | | - | |
| 22 | + | |
| 23 | + | |
21 | 24 | | |
22 | 25 | | |
23 | 26 | | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
24 | 32 | | |
25 | | - | |
26 | | - | |
27 | | - | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
28 | 36 | | |
29 | 37 | | |
30 | 38 | | |
31 | 39 | | |
32 | | - | |
33 | | - | |
34 | 40 | | |
35 | 41 | | |
36 | 42 | | |
| |||
46 | 52 | | |
47 | 53 | | |
48 | 54 | | |
49 | | - | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
50 | 62 | | |
51 | 63 | | |
52 | 64 | | |
| |||
253 | 265 | | |
254 | 266 | | |
255 | 267 | | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
256 | 329 | | |
| 330 | + | |
| 331 | + | |
257 | 332 | | |
258 | 333 | | |
259 | 334 | | |
| |||
0 commit comments