Skip to content

feat: support OpenResty 1.29.2 patch#20

Merged
nic-6443 merged 2 commits into
masterfrom
openresty-1.29.2-patches
May 22, 2026
Merged

feat: support OpenResty 1.29.2 patch#20
nic-6443 merged 2 commits into
masterfrom
openresty-1.29.2-patches

Conversation

@jarvis9443
Copy link
Copy Markdown
Contributor

@jarvis9443 jarvis9443 commented May 21, 2026

Adds the nginx 1.29.2 patch mapping used by OpenResty 1.29.2.x so the module can be built by apisix-runtime based on OpenResty 1.29.2.

Validation:

  • git diff --check
  • bash -n patch.sh
  • applied ./patch.sh to OpenResty 1.29.2.4 source

Summary by CodeRabbit

  • New Features

    • Adds optional multi-upstream support to coordinate concurrent upstream connections, request queuing/waiting, improved SSL/non-buffered handling, and specialized upstream progression for multi-connection scenarios.
  • Chores

    • Updated patch script to detect its own location and add support for openresty-1.29.2.x patch application.

Review Change Stack

Copilot AI review requested due to automatic review settings May 21, 2026 09:07
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 21, 2026

📝 Walkthrough

Walkthrough

This PR adds conditional multi-upstream support to nginx 1.29.2 by extending core data structures (connection, request, upstream, stream session) with queue and state-tracking fields, integrating multi-upstream module entry points throughout the HTTP upstream request/response lifecycle, and updating the patch script to recognize and apply the patch to OpenResty 1.29.2 bundles.

Changes

nginx 1.29.2 multi-upstream integration

Layer / File(s) Summary
Core data structure extensions
src/core/ngx_connection.h, src/http/ngx_http_request.h, src/http/ngx_http_upstream.h, src/stream/ngx_stream.h, src/stream/ngx_stream_upstream.h
Adds T_NGX_MULTI_UPSTREAM-guarded fields: ngx_connection_s.multi_c, request/session queue pointers and waiting_queue/waiting flags, and upstream fields multi, multi_init, send_pool, and multi_mode.
HTTP upstream control flow integration
src/http/ngx_http_upstream.c
Conditionally includes/inline multi-upstream code and adds multi-aware branches at connect (NGX_AGAIN/NGX_DONE/error), SSL handshake early init, request send (enqueue waiting requests), read handler diversion, body-send cleanup, non-buffered processing delegation, and interception of next/finalize for fake multi connections.
Build script version detection
patch.sh
Resolves patch paths relative to the script and adds an openresty-1.29.2.* branch selecting nginx-1.29.2.patch and targeting $1/bundle/nginx-1.29.2.

🎯 4 (Complex) | ⏱️ ~45 minutes

🚥 Pre-merge checks | ✅ 5 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
E2e Test Quality Review ⚠️ Warning PR lacks E2E tests entirely. Repository has no test directory, CI/CD pipeline, or automated tests verifying patch application, compilation, or runtime correctness against OpenResty 1.29.2.x bundles. Add E2E tests using GitHub Actions that (1) apply the patch to OpenResty 1.29.2.x, (2) verify compilation succeeds, and (3) test multi-upstream module functionality works correctly.
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: support OpenResty 1.29.2 patch' accurately describes the main objective of the PR: adding support for a new OpenResty version by introducing a corresponding nginx patch and version detection in patch.sh.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Security Check ✅ Passed Connection management patch. Logs contain only debug messages/pointers, no credentials. Proper error handling. Security categories 2-7 do not apply to this Nginx module.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch openresty-1.29.2-patches

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds OpenResty 1.29.2.x support by mapping it to an nginx 1.29.2 patch, keeping this module buildable when bundled with newer OpenResty (e.g., in apisix-runtime).

Changes:

  • Extend patch.sh to detect openresty-1.29.2.* and apply the corresponding nginx patch.
  • Add nginx-1.29.2.patch to inject T_NGX_MULTI_UPSTREAM-guarded multi-upstream hooks/struct fields into the nginx 1.29.2 sources.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
patch.sh Adds OpenResty 1.29.2 version detection and selects the new patch + bundle dir.
nginx-1.29.2.patch New nginx patch enabling multi-upstream integration points for nginx 1.29.2 used by OpenResty 1.29.2.x.
Comments suppressed due to low confidence (1)

nginx-1.29.2.patch:104

  • Log message grammar is unclear: "upstream not support" is ungrammatical and may confuse users. Consider rephrasing to "upstream does not support multi" / "upstream is not configured for multi" so the operator action is unambiguous.
+                                           NGX_HTTP_INTERNAL_SERVER_ERROR);
+        ngx_log_error(NGX_LOG_ERR, c->log, 0,
+                      "multi: need multi, but upstream not support, "
+                      "maybe need configuration 'multi' in upstream");
+        return;

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread patch.sh
Comment thread nginx-1.29.2.patch Outdated
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@nginx-1.29.2.patch`:
- Around line 200-207: The current log call inside the
ngx_http_upstream_finalize_request path logs fake-request finalization at
NGX_LOG_ERR and produces false errors; change the log level to a non-error level
(e.g., NGX_LOG_INFO or NGX_LOG_DEBUG) or conditionally log NGX_LOG_ERR only when
rc indicates a real failure (check rc against NGX_OK/NGX_ERROR as appropriate)
in the block that checks u->multi and ngx_http_multi_connection_fake(r) before
calling ngx_http_multi_upstream_finalize_request(r->connection, rc); keep the
same message and parameters but use the lower log level or conditional to avoid
spurious error entries.
- Around line 81-97: When rc == NGX_DONE and ngx_multi_connected(c) returns
false the code currently only logs and returns, leaving r unattached and
hanging; change this branch to explicitly finalize the request instead of
returning. Specifically, in the else block under "if (rc == NGX_DONE)" call
ngx_http_multi_upstream_finalize_request(c, NGX_HTTP_INTERNAL_SERVER_ERROR) (or
another appropriate failure code) and log the failure, rather than just
ngx_log_error then return; do not alter the existing success path that calls
ngx_http_multi_upstream_init_request(c, r) and
ngx_http_multi_upstream_process(c, 1).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6f3ac23d-53d9-4c44-bb95-aa525f1b0f7b

📥 Commits

Reviewing files that changed from the base of the PR and between 0c9e4ce and 0081acf.

📒 Files selected for processing (2)
  • nginx-1.29.2.patch
  • patch.sh

Comment thread nginx-1.29.2.patch
Comment thread nginx-1.29.2.patch
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
nginx-1.29.2.patch (1)

65-98: ⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Fix potential use-after-close: log c->log before ngx_http_multi_upstream_finalize_request(c, ...)

ngx_http_multi_upstream_finalize_request() detaches and then calls ngx_http_multi_upstream_connection_close(c), which destroys c->pool and calls ngx_close_connection(c). Logging after it (using c->log / c) can touch an invalid c.

Suggested reordering
     if (!(u->multi_mode & NGX_MULTI_UPS_SUPPORT_MULTI)) {
+        ngx_log_error(NGX_LOG_ERR, c->log, 0,
+                      "multi: upstream configured multi, but handler does not support it");
         ngx_http_multi_upstream_finalize_request(c,
                                                      NGX_HTTP_INTERNAL_SERVER_ERROR);
-        ngx_log_error(NGX_LOG_ERR, c->log, 0,
-                      "multi: upstream configured multi, but handler does not support it");
         return;
     }
     } else {
+        ngx_log_error(NGX_LOG_ERR, c->log, 0,
+                      "multi: connect return %i error", rc);
         ngx_http_multi_upstream_finalize_request(c,
                                                      NGX_HTTP_INTERNAL_SERVER_ERROR);
-        ngx_log_error(NGX_LOG_ERR, c->log, 0,
-                      "multi: connect return %i error", rc);
     }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@nginx-1.29.2.patch` around lines 65 - 98, The code logs using c and c->log
after calling ngx_http_multi_upstream_finalize_request(c, ...) which can free c
(via ngx_http_multi_upstream_connection_close and ngx_close_connection); move
any ngx_log_error calls that reference c or c->log to occur before
ngx_http_multi_upstream_finalize_request is invoked (and do the same for the
branch that calls ngx_http_upstream_finalize_request(r, u, ...)), ensuring you
log the error context first, then call ngx_http_multi_upstream_finalize_request
or ngx_http_upstream_finalize_request so no logging touches a potentially freed
connection object; locate these changes around the ngx_http_multi_upstream_*
handlers and branches that check rc, ngx_multi_connected, and the error
branches.
🧹 Nitpick comments (1)
nginx-1.29.2.patch (1)

159-163: 💤 Low value

Minor: Inconsistent preprocessor guard style.

Line 159 uses #if T_NGX_MULTI_UPSTREAM without parentheses, while all other occurrences in this patch use #if (T_NGX_MULTI_UPSTREAM) with parentheses.

Consistent style
-#if T_NGX_MULTI_UPSTREAM
+#if (T_NGX_MULTI_UPSTREAM)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@nginx-1.29.2.patch` around lines 159 - 163, The preprocessor guard around the
multi-upstream cleanup is inconsistent; change the directive `#if
T_NGX_MULTI_UPSTREAM` to use the same parenthesized style `#if
(T_NGX_MULTI_UPSTREAM)` so it matches other guards in the patch; keep the inner
logic unchanged (the `if (u->multi && rc == NGX_OK) {
ngx_multi_clean_leak(u->peer.connection); }` block and the `#endif`) and ensure
spacing/indentation follows surrounding code.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@nginx-1.29.2.patch`:
- Around line 65-98: The code logs using c and c->log after calling
ngx_http_multi_upstream_finalize_request(c, ...) which can free c (via
ngx_http_multi_upstream_connection_close and ngx_close_connection); move any
ngx_log_error calls that reference c or c->log to occur before
ngx_http_multi_upstream_finalize_request is invoked (and do the same for the
branch that calls ngx_http_upstream_finalize_request(r, u, ...)), ensuring you
log the error context first, then call ngx_http_multi_upstream_finalize_request
or ngx_http_upstream_finalize_request so no logging touches a potentially freed
connection object; locate these changes around the ngx_http_multi_upstream_*
handlers and branches that check rc, ngx_multi_connected, and the error
branches.

---

Nitpick comments:
In `@nginx-1.29.2.patch`:
- Around line 159-163: The preprocessor guard around the multi-upstream cleanup
is inconsistent; change the directive `#if T_NGX_MULTI_UPSTREAM` to use the same
parenthesized style `#if (T_NGX_MULTI_UPSTREAM)` so it matches other guards in
the patch; keep the inner logic unchanged (the `if (u->multi && rc == NGX_OK) {
ngx_multi_clean_leak(u->peer.connection); }` block and the `#endif`) and ensure
spacing/indentation follows surrounding code.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c35c8e09-b6bc-4d9e-b132-3e948c4d8d8d

📥 Commits

Reviewing files that changed from the base of the PR and between 0081acf and 125e594.

📒 Files selected for processing (2)
  • nginx-1.29.2.patch
  • patch.sh

@nic-6443 nic-6443 merged commit 3ac93f2 into master May 22, 2026
2 checks passed
@nic-6443 nic-6443 deleted the openresty-1.29.2-patches branch May 22, 2026 01:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants