Commit 46974e9
authored
Fix IP address being labelled "bad" for too long (#718)
**Issue:**
A server went offline for a while to do some updates. But when it came back online later, it wasn't getting any traffic. The expectation is that traffic to this server would eventually resume.
**Diagnosis:**
The default host resolver has a "bad" list of addresses (connect attempt failed). The idea is: don't use these addresses unless there are NO known good addresses.
Due to quirks of the code, addresses in the "bad' list would not be removed when their TTL expired. Maybe this was an accident? Maybe the author just wanted to avoid some looping?
In any case, this could result in the address being labeled "bad" FOREVER. Even if the server and DNS did the right thing: not reporting the address while the server was offline but reporting it again later when everything was good, the aws_host_resolver cache would still have the address in its "bad" list.
The only way to get off the bad list would be if ALL good addresses failed, and the resolver was forced to pull from the bad list.
But we need to handle a reasonable world, where an address might randomly go bad for a while and get better later.
**Description of changes:**
- Remove addresses in the bad list when their TTL expires
- TTL is currently [30sec by default](https://github.com/awslabs/aws-c-io/blob/9c7c52cb0d61b6644e6fb1973fcd680d62435ac7/source/host_resolver.c#L23-L24), [5min for aws-c-s3](https://github.com/awslabs/aws-c-s3/blob/169842b7e2f81d71d0719d4a77f9c3e186512f99/source/s3_client.c#L81-L82) (these may change in the future)
- If an address is in the "bad" list, but DNS is still reporting it, don't update its TTL.
So now, if there's a failed connection, the address will remain on the "bad" list until its TTL expires, even if that address appears in future DNS queries. Then, the address will be removed from all caches. If a future DNS query returns that address again, it will go into the "good" list.1 parent 2efcac7 commit 46974e9
File tree
3 files changed
+216
-25
lines changed- source
- tests
3 files changed
+216
-25
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
520 | 520 | | |
521 | 521 | | |
522 | 522 | | |
523 | | - | |
524 | | - | |
525 | | - | |
526 | | - | |
527 | | - | |
528 | | - | |
529 | | - | |
530 | | - | |
531 | | - | |
532 | | - | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
533 | 539 | | |
534 | 540 | | |
535 | 541 | | |
| |||
558 | 564 | | |
559 | 565 | | |
560 | 566 | | |
561 | | - | |
| 567 | + | |
562 | 568 | | |
563 | 569 | | |
564 | 570 | | |
| |||
703 | 709 | | |
704 | 710 | | |
705 | 711 | | |
706 | | - | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
707 | 718 | | |
708 | 719 | | |
709 | 720 | | |
710 | 721 | | |
711 | 722 | | |
| 723 | + | |
712 | 724 | | |
713 | 725 | | |
714 | 726 | | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
715 | 730 | | |
716 | 731 | | |
717 | | - | |
| 732 | + | |
718 | 733 | | |
719 | 734 | | |
720 | 735 | | |
721 | 736 | | |
722 | 737 | | |
723 | | - | |
| 738 | + | |
724 | 739 | | |
725 | 740 | | |
726 | 741 | | |
| |||
733 | 748 | | |
734 | 749 | | |
735 | 750 | | |
736 | | - | |
| 751 | + | |
737 | 752 | | |
738 | 753 | | |
739 | 754 | | |
| |||
779 | 794 | | |
780 | 795 | | |
781 | 796 | | |
782 | | - | |
| 797 | + | |
783 | 798 | | |
784 | 799 | | |
785 | | - | |
786 | | - | |
787 | | - | |
788 | | - | |
789 | | - | |
790 | | - | |
791 | | - | |
792 | | - | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
793 | 819 | | |
794 | | - | |
| 820 | + | |
795 | 821 | | |
796 | 822 | | |
797 | 823 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
| 116 | + | |
116 | 117 | | |
117 | 118 | | |
118 | 119 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1060 | 1060 | | |
1061 | 1061 | | |
1062 | 1062 | | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
| 1072 | + | |
| 1073 | + | |
| 1074 | + | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
| 1119 | + | |
| 1120 | + | |
| 1121 | + | |
| 1122 | + | |
| 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 | + | |
| 1155 | + | |
| 1156 | + | |
| 1157 | + | |
| 1158 | + | |
| 1159 | + | |
| 1160 | + | |
| 1161 | + | |
| 1162 | + | |
| 1163 | + | |
| 1164 | + | |
| 1165 | + | |
| 1166 | + | |
| 1167 | + | |
| 1168 | + | |
| 1169 | + | |
| 1170 | + | |
| 1171 | + | |
| 1172 | + | |
| 1173 | + | |
| 1174 | + | |
| 1175 | + | |
| 1176 | + | |
| 1177 | + | |
| 1178 | + | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
| 1200 | + | |
| 1201 | + | |
| 1202 | + | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
1063 | 1227 | | |
1064 | 1228 | | |
1065 | 1229 | | |
| |||
0 commit comments