Copilot commented on code in PR #13885:
URL: https://github.com/apache/trafficserver/pull/13885#discussion_r4343901082


##########
src/proxy/http/HttpSM.cc:
##########
@@ -4945,7 +4945,7 @@ HttpSM::track_connect_fail() const
   // Excludes two cases:
   // - Reused keep-alive connection: there is a known race between ATS reusing 
and the origin closing it.
   // - Multiplexed origins (HTTP/2): stream-level failure does not indicate a 
connection failure.
-  if (policy >= 4) {
+  if (policy >= 4 && server_txn != nullptr) {

Review Comment:
   The null check fixes the crash, but the reason `server_txn` can be null here 
(connect failure before a server transaction exists, e.g., 
`server_max_connections` refusal / direct-path connect error) isn’t obvious 
from the code. Adding a brief comment near this guard (or an early-return with 
comment) would make the behavior intentional and reduce the chance of a future 
refactor reintroducing the dereference issue.



##########
tests/uranium_tests/connect_down_policy/replay/connect_down_policy_4_no_connect.test.yaml:
##########
@@ -0,0 +1,97 @@
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information
+#  regarding copyright ownership.  The ASF licenses this file
+#  to you under the Apache License, Version 2.0 (the
+#  "License"); you may not use this file except in compliance
+#  with the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+
+meta:
+  version: "1.0"
+
+urtest:
+  description: 'Verify connect down policy 4 when the origin connection was 
never opened'
+
+  dns:
+    name: 'dns-policy-4-no-connect'
+    records:
+      backend.example.com: ["127.0.0.1"]
+
+  server:
+    name: 'server-policy-4-no-connect'
+
+  client:
+    name: 'client-policy-4-no-connect'
+    process_config:
+      run_parallel: true
+
+  ats:
+    name: 'ts-policy-4-no-connect'
+    process_config:
+      enable_cache: false
+
+    records_config:
+      proxy.config.diags.debug.enabled: 1
+      proxy.config.diags.debug.tags: 'http|hostdb'
+      proxy.config.http.connect.down.policy: 4
+      proxy.config.http.connect_attempts_max_retries: 0
+      # The slow transaction holds the only allowed origin connection, so the 
second one is refused before connecting.
+      proxy.config.http.server_max_connections: 1
+
+    remap_config:
+      - from: "http://slow.example.com/";
+        to: "http://backend.example.com:{SERVER_HTTP_PORT}/";
+      - from: "http://refused.example.com/";
+        to: "http://backend.example.com:{SERVER_HTTP_PORT}/";
+
+    log_validation:
+      traffic_out:
+        excludes:
+          - expression: "hostdb update marking IP: .* as down"
+            description: "a connect refused before an origin connection exists 
must not mark the origin down"
+
+sessions:
+- transactions:
+  - client-request:
+      method: GET
+      url: /slow/
+      version: '1.1'
+      headers:
+        fields:
+        - [Host, slow.example.com]
+        - [uuid, slow]
+
+    server-response:
+      delay: 2s
+      status: 200
+
+    proxy-response:
+      status: 200
+
+- transactions:
+  - client-request:
+      delay: 500ms
+      method: GET
+      url: /refused/
+      version: '1.1'
+      headers:
+        fields:
+        - [Host, refused.example.com]
+        - [uuid, refused]
+
+    proxy-request:
+      expect: absent
+
+    server-response:
+      status: 200
+

Review Comment:
   This transaction declares `proxy-request: expect: absent` (meaning ATS must 
not send anything to the origin), but still defines a `server-response`. In 
most uranium replay setups, a `server-response` implies the server received a 
request and is replying, which contradicts `expect: absent` and can make the 
test flaky or misleading. Consider removing the `server-response` for this 
transaction, or marking the server side as absent/unused in whatever way this 
harness supports for ‘no origin request’ cases.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to