Repository navigation
Commit a73d970
committed
cachedb_perf: cross-node pull - ask the cluster before calling a miss
Nodes behind a load balancer each run their own cachedb_perf, so a key
written on one node is a miss on every other until something moves it.
perf_sync (the existing mechanism) moves whole collections through a shared
DB - right for bootstrap and failover, wrong for one key: a full snapshot per
convergence event, and only when someone asks for one.
This adds the per-key path: on a miss, ask the cluster, and store what comes
back. Opt-in per collection via replicate_collections - a key is only worth
asking the cluster about if it means the same thing on every node, which only
the operator knows.
Protocol. A miss allocates a slot in a small shm pool, broadcasts a request
carrying (collection, key, id), and peers that hold the key answer with the
value and its remaining TTL; the reply is stored locally with that TTL and
the slot is released. Slots have a deadline (pull_timeout_ms, default 50);
a utimer reaper fires twice per timeout window and releases every slot whose
deadline passed - without it, a request no peer answers would leak its slot
AND leave a blocked worker hanging forever, which is exactly what happened in
an early deployment when fewer peers than expected were up. Answers arriving
after the deadline are stored anyway (the data is still good - only the
waiter is gone). A miss the whole cluster confirmed is remembered in a small
negative cache for pull_negative_ms, so a key that does not exist anywhere
does not re-interrogate the cluster on every lookup.
Blocking is explicit and bounded. pull_on_miss=1 makes a cache_fetch miss
wait (poll + eventfd) up to pull_timeout_ms for the cluster's answer - that
is a worker parked per miss, fine for a maintenance path, priced accordingly
on a SIP path, and the module says so at startup. With it off, the pull
still happens asynchronously and benefits the NEXT lookup of that key.
Transports. Default "bin" rides the clusterer module's BIN links: one
unicast per peer, no extra dependency. "clctr" rides the
clusterer_controller module's encrypted multicast plane instead - one
datagram reaches every peer, encrypted, which the BIN links are not. The
controller is optional at build time (CLUSTERER_CTRL_SUPPORT, exported by
the top-level Makefile only when clusterer_controller is part of the build)
and at run time: a clctr choice the deployment cannot honour warns and
degrades to bin, and if the clusterer module is unavailable too, pull and
sync are disabled and the cache runs purely node-local. Missing cluster
infrastructure never stops the module from starting.
Sizing is measured, not guessed. A pull slot embeds its key and value
bounds; pull_max_key (default 128) and pull_max_value (default 512) size
them, so the 64-slot pool costs 50 KB of shm at the defaults instead of the
550 KB a worst-case constant would take. The defaults come from measuring
live collections (values of 1-20 bytes under keys up to 33; sql_cacher rows
~70 bytes); dns_cache-style users with multi-KB records raise pull_max_value
and accept fewer slots per KB. A value over the cap - or, on the clctr
plane, over what one datagram can carry - is answered as held-but-unsendable
rather than absent: the requester must not conclude a key is missing from a
node that demonstrably holds it. It falls back to the DB path untouched.
Failover hook. sync_shtag="name/cluster_id" arms a sharing-tag callback:
the node becoming active reloads the collections from the DB snapshot, so a
standby that just took over does not serve week-old state. Like everything
else here it is soft - no DB or no clusterer means it logs and disarms.
Observability. Module stats pull_requested / pull_answered / pull_served /
pull_timeouts / pull_negative_hits, plus per-collection pulled_in /
served_out (the module-wide counters cannot say WHICH collection is
converging). perf_stats gains a cluster.topology object naming this node's
id, resolved IP and each peer's reachability; perf_cluster_probe actively
asks every peer to answer for a collection and reports who did - the two
questions (who is configured / who is actually reachable) fail differently.
The pullsoak rig under bench/ drives all of it against a real two-node
cluster: the e2e burst, the async slot-leak regression (the reaper bug
above, reproduced first, then fixed), the oversize leg, and the max-key
boundary.1 parent fea6b19 commit a73d970
22 files changed
Lines changed: 3799 additions & 72 deletions
File tree
- modules/cachedb_perf
- bench/pullsoak
- doc
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
9 | 18 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
30 | 36 | | |
31 | 37 | | |
32 | 38 | | |
| |||
36 | 42 | | |
37 | 43 | | |
38 | 44 | | |
39 | | - | |
40 | | - | |
| 45 | + | |
| 46 | + | |
41 | 47 | | |
42 | 48 | | |
43 | 49 | | |
| |||
74 | 80 | | |
75 | 81 | | |
76 | 82 | | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
86 | 94 | | |
87 | 95 | | |
88 | 96 | | |
| |||
339 | 347 | | |
340 | 348 | | |
341 | 349 | | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
342 | 468 | | |
343 | 469 | | |
344 | 470 | | |
| |||
416 | 542 | | |
417 | 543 | | |
418 | 544 | | |
419 | | - | |
| 545 | + | |
420 | 546 | | |
421 | 547 | | |
422 | 548 | | |
| |||
491 | 617 | | |
492 | 618 | | |
493 | 619 | | |
494 | | - | |
| 620 | + | |
495 | 621 | | |
496 | 622 | | |
497 | 623 | | |
| |||
519 | 645 | | |
520 | 646 | | |
521 | 647 | | |
522 | | - | |
| 648 | + | |
523 | 649 | | |
524 | 650 | | |
525 | 651 | | |
526 | 652 | | |
527 | | - | |
| 653 | + | |
528 | 654 | | |
529 | 655 | | |
530 | 656 | | |
| |||
548 | 674 | | |
549 | 675 | | |
550 | 676 | | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
551 | 694 | | |
552 | 695 | | |
553 | 696 | | |
| |||
560 | 703 | | |
561 | 704 | | |
562 | 705 | | |
563 | | - | |
| 706 | + | |
564 | 707 | | |
565 | 708 | | |
566 | 709 | | |
| |||
579 | 722 | | |
580 | 723 | | |
581 | 724 | | |
582 | | - | |
| 725 | + | |
583 | 726 | | |
584 | 727 | | |
585 | 728 | | |
| |||
590 | 733 | | |
591 | 734 | | |
592 | 735 | | |
593 | | - | |
| 736 | + | |
594 | 737 | | |
595 | 738 | | |
596 | 739 | | |
| |||
656 | 799 | | |
657 | 800 | | |
658 | 801 | | |
659 | | - | |
| 802 | + | |
660 | 803 | | |
661 | 804 | | |
662 | 805 | | |
| |||
671 | 814 | | |
672 | 815 | | |
673 | 816 | | |
674 | | - | |
| 817 | + | |
675 | 818 | | |
676 | 819 | | |
677 | 820 | | |
| |||
687 | 830 | | |
688 | 831 | | |
689 | 832 | | |
690 | | - | |
| 833 | + | |
691 | 834 | | |
692 | 835 | | |
693 | 836 | | |
| |||
| 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 | + | |
0 commit comments