Commit d999e24
committed
server,rpc: validate node IDs in RPC heartbeats
Prior to this patch, it was possible for a RPC client to dial a node
ID and get a connection to another node instead. This is because the
mapping of node ID -> address may be stale, and a different node could
take the address of the intended node from "under" the dialer.
(See the previous commit for a scenario.)
This happened to be "safe" in many cases where it matters because:
- RPC requests for distSQL are OK with being served on a different
node than intended (with potential performance drop);
- RPC requests to the KV layer are OK with being served on a different
node than intended (they would route underneath);
- RPC requests to the storage layer are rejected by the
remote node because the store ID in the request would not match.
However this safety is largely accidental, and we should not work with
the assumption that any RPC request is safe to be mis-routed. (In
fact, we have not audited all the RPC endpoints and cannot establish
this safety exists throughout.)
This patch works to prevent these mis-routings by adding a check of
the intended node ID during RPC heartbeats (including the initial
heartbeat), when the intended node ID is known. A new API
`GRPCDialNode()` is introduced to establish such connections.
Release note (bug fix): CockroachDB now performs fewer attempts to
communicate with the wrong node, when a node is restarted with another
node's address.1 parent 295b6ae commit d999e24
File tree
18 files changed
+326
-78
lines changed- pkg
- gossip
- rpc
- nodedialer
- server
- sql/distsqlrun
- storage
- testutils/localtestcluster
18 files changed
+326
-78
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| 69 | + | |
69 | 70 | | |
70 | 71 | | |
71 | 72 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | | - | |
65 | | - | |
| 64 | + | |
66 | 65 | | |
67 | 66 | | |
68 | 67 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
253 | 253 | | |
254 | 254 | | |
255 | 255 | | |
| 256 | + | |
256 | 257 | | |
257 | 258 | | |
258 | 259 | | |
| |||
272 | 273 | | |
273 | 274 | | |
274 | 275 | | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
275 | 281 | | |
276 | 282 | | |
277 | 283 | | |
278 | 284 | | |
279 | | - | |
| 285 | + | |
280 | 286 | | |
281 | 287 | | |
282 | 288 | | |
| 289 | + | |
283 | 290 | | |
284 | 291 | | |
285 | 292 | | |
| |||
346 | 353 | | |
347 | 354 | | |
348 | 355 | | |
| 356 | + | |
349 | 357 | | |
350 | 358 | | |
351 | 359 | | |
352 | 360 | | |
353 | 361 | | |
354 | 362 | | |
355 | 363 | | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
356 | 372 | | |
357 | 373 | | |
358 | 374 | | |
| |||
396 | 412 | | |
397 | 413 | | |
398 | 414 | | |
399 | | - | |
| 415 | + | |
400 | 416 | | |
401 | 417 | | |
402 | 418 | | |
| |||
518 | 534 | | |
519 | 535 | | |
520 | 536 | | |
521 | | - | |
| 537 | + | |
522 | 538 | | |
523 | 539 | | |
524 | | - | |
| 540 | + | |
525 | 541 | | |
526 | 542 | | |
527 | 543 | | |
528 | 544 | | |
529 | | - | |
| 545 | + | |
530 | 546 | | |
531 | 547 | | |
532 | 548 | | |
| |||
650 | 666 | | |
651 | 667 | | |
652 | 668 | | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
653 | 674 | | |
654 | | - | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
655 | 685 | | |
656 | | - | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
657 | 698 | | |
658 | 699 | | |
659 | 700 | | |
| |||
668 | 709 | | |
669 | 710 | | |
670 | 711 | | |
671 | | - | |
| 712 | + | |
672 | 713 | | |
673 | 714 | | |
674 | 715 | | |
675 | | - | |
| 716 | + | |
676 | 717 | | |
677 | 718 | | |
678 | 719 | | |
| |||
703 | 744 | | |
704 | 745 | | |
705 | 746 | | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
706 | 750 | | |
707 | 751 | | |
708 | 752 | | |
| |||
716 | 760 | | |
717 | 761 | | |
718 | 762 | | |
719 | | - | |
| 763 | + | |
720 | 764 | | |
721 | | - | |
722 | | - | |
723 | | - | |
724 | | - | |
725 | | - | |
726 | | - | |
727 | 765 | | |
728 | 766 | | |
729 | 767 | | |
| |||
748 | 786 | | |
749 | 787 | | |
750 | 788 | | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
751 | 798 | | |
752 | 799 | | |
753 | | - | |
| 800 | + | |
754 | 801 | | |
755 | 802 | | |
756 | 803 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
| 96 | + | |
96 | 97 | | |
97 | 98 | | |
98 | 99 | | |
| |||
341 | 342 | | |
342 | 343 | | |
343 | 344 | | |
| 345 | + | |
344 | 346 | | |
345 | 347 | | |
346 | 348 | | |
| |||
515 | 517 | | |
516 | 518 | | |
517 | 519 | | |
| 520 | + | |
518 | 521 | | |
519 | 522 | | |
520 | 523 | | |
| |||
682 | 685 | | |
683 | 686 | | |
684 | 687 | | |
| 688 | + | |
685 | 689 | | |
686 | 690 | | |
687 | 691 | | |
| |||
829 | 833 | | |
830 | 834 | | |
831 | 835 | | |
| 836 | + | |
832 | 837 | | |
833 | 838 | | |
834 | 839 | | |
| |||
1011 | 1016 | | |
1012 | 1017 | | |
1013 | 1018 | | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
1014 | 1063 | | |
1015 | 1064 | | |
1016 | 1065 | | |
| |||
1048 | 1097 | | |
1049 | 1098 | | |
1050 | 1099 | | |
| 1100 | + | |
1051 | 1101 | | |
1052 | 1102 | | |
1053 | 1103 | | |
| |||
1056 | 1106 | | |
1057 | 1107 | | |
1058 | 1108 | | |
| 1109 | + | |
1059 | 1110 | | |
1060 | 1111 | | |
1061 | 1112 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| |||
48 | 49 | | |
49 | 50 | | |
50 | 51 | | |
| 52 | + | |
51 | 53 | | |
52 | 54 | | |
53 | 55 | | |
| |||
74 | 76 | | |
75 | 77 | | |
76 | 78 | | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
77 | 93 | | |
78 | 94 | | |
79 | 95 | | |
80 | 96 | | |
81 | 97 | | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
82 | 101 | | |
83 | 102 | | |
84 | 103 | | |
85 | 104 | | |
86 | 105 | | |
87 | 106 | | |
88 | 107 | | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
89 | 125 | | |
90 | 126 | | |
91 | 127 | | |
| |||
0 commit comments