Repository navigation
Conversation
Deliver milestone M0 of #8184: a design note for the dedicated native gRPC proxy plugin, with no implementation and no runtime change. Grounds the design in current code rather than assertion: records the six concrete breakpoints that make the existing HTTP/JSON bridge unsuitable as a base (ServerWebExchange binding, JSON error bodies, response aggregation in MessageWriter, cancellation not crossing the CompletableFuture bridge, ThreadLocal gRPC Context propagation, JSON-envelope service renamed with a JSON suffix), and lists what is reusable instead. Covers naming and compatibility boundary (grpc-proxy new, grpc identifier and wire contract unchanged, grpc-http as display name only), module layout and dependency direction, all six SQL dialects plus the native-sql-matrix CI gate, listener lifecycle that discriminates restart-class from snapshot-class configuration so unrelated edits cannot sever long-lived streams, per-call context with exactly-once terminal accounting, immutable snapshot publication with reload-safe admission accounting, upstream channel pooling coordinated with #8207, marker-based circuit-breaker classification per #8189, streaming governance boundaries, trust boundary, status/trailer mapping, per-RPC-stream routing granularity, verification strategy, acceptance-criteria mapping, milestone plan M0-M6, risks and open questions.
Aias00
left a comment
There was a problem hiding this comment.
Reviewed 2af0190.
The native/HTTP-JSON compatibility boundary and the per-call forwarding/resource model are grounded in the existing code. One concrete listener-lifecycle sequence needs correction before this becomes the implementation plan: a same-port replacement cannot be started while the old listener still owns the bind. Verified with a real grpc-java 1.65.1 listener bind probe; this is not a claim that the future native proxy implementation or four-RPC-type E2E has been tested.
Checkstyle (where Java was built), separately executed Apache RAT and git diff --check pass. No full repository/E2E pass is claimed.
|
|
||
| | Configuration class | Examples | On change | | ||
| | --- | --- | --- | | ||
| | **restart-class** | port, TLS/ALPN material, cleartext policy, executor/thread sizing, transport-level message size limits | Start a new listener, stop accepting on the old one, drain established calls to a deadline, then release old resources. Never a bare `shutdown()`. | |
There was a problem hiding this comment.
[P2] Release the old socket before starting a same-port replacement
This restart sequence starts the new listener before stopping acceptance on the old listener, but restart-class changes include TLS, executors and transport limits without changing the address/port. Two ordinary grpc-java listeners cannot bind that same socket concurrently. With pinned grpc-java 1.65.1, a loopback probe starting the second NettyServerBuilder on the first server port fails with BindException: Address already in use. Distinguish a new-port replacement from a same-port restart: release the old listening socket through orderly shutdown before binding the replacement, while retaining active calls and their executors/channel leases until drain completes. Document the bind-failure/rollback behavior and any bounded acceptance gap. Server.shutdown() is graceful for existing RPCs; it need not mean terminating their streams.
There was a problem hiding this comment.
Fixed in cd7faca. You are right — the previous sequence started the replacement before releasing the old socket, which cannot work for the common restart-class changes (TLS, executors, transport limits) that keep the same address/port.
Section 6.3 now:
- Distinguishes the two cases. Same-port restart: orderly
Server.shutdown()on the old server first (rejects new calls, releases the listening socket on return, preexisting calls continue), then build+start()the replacement on the freed port; the old server's executors and channel leases are retained until drain finishes viaawaitTermination(deadline), escalating toshutdownNow()only on deadline expiry or immediate security revocation. New-port replacement: start the new listener first (no bind conflict, no acceptance gap), then shutdown+drain the old one. - Corrects the
shutdown()conflation. The immediacy concern is the MQTT handler's own teardown (channel +shutdownGracefully()on both event loop groups), not grpc-java'sServer.shutdown(), which at the pinned 1.65.1 is orderly and per its contract releases the listening socket so it "may be reused by another server". The old "never a bareshutdown()" line was wrong and is gone. - Documents the bounded acceptance gap (socket release + one bind; affects only new calls) and bind-failure/rollback: since a shut-down
Servercannot be restarted (start()throwsIllegalStateException), rollback builds a freshServerfrom the retained old config while in-flight calls keep draining; if that also fails the listener stays down, is surfaced, and retried, with snapshot/permit/lease state (section 8.3) surviving.
Also propagated to the risk table, the shenyu-protocol-grpc-native test bullet, and a new open question (#10) on whether the same-port acceptance gap is operationally acceptable or zero-gap new-port restarts should be required.
Address review on #8218 (section 6.3). Two grpc-java listeners cannot bind the same socket concurrently (verified BindException at pinned 1.65.1), so a same-port restart must release the old socket via orderly Server.shutdown() before binding the replacement, not start the new listener first. - Distinguish same-port restart (shutdown releases socket, then rebind, drain retained executors/channel leases) from new-port replacement (start first, no bind conflict, no acceptance gap). - Clarify that grpc-java Server.shutdown() is orderly (preexisting calls continue, socket released on return) and that the immediacy concern is the MQTT handler's own teardown, not Server.shutdown(). - Document the bounded acceptance gap and bind-failure/rollback: a shut-down Server cannot be restarted, so rollback builds a fresh Server; snapshot, permit accounting and leases survive the outage. - Extend the risk table, module test bullet and open questions accordingly.
|
@Aias00 Thanks for the precise catch — you were right that the previous restart sequence could not work for the common case. Addressed in cd7faca (section 6.3), and re-requested your review. The old text started the replacement listener before releasing the old socket. Since most restart-class changes (TLS/ALPN, cleartext policy, executor/thread sizing, transport-level message-size limits) keep the same address/port, and two grpc-java listeners cannot bind one socket concurrently ( Section 6.3 now:
Also propagated to the risk table (section 16), the |
|
@Aias00 Gentle ping for re-review when you have a moment. The single review item (same-port listener restart ordering) was corrected in cd7faca — section 6.3 now shuts the old server down before binding the replacement, with the two restart cases distinguished — and the branch has just been synced with master (merge commit 07c8096, CI green). Happy to adjust anything else you spot. |
What this PR does
Delivers milestone M0 (architecture/design) of #8184: a design note for the dedicated native gRPC proxy plugin, at
docs/grpc-proxy-architecture.md(17 sections).Documentation only. No implementation and no runtime change — no new module, no
PluginEnumentry, no database row, no starter, no behavior change.Related Issue
Refs: #8184
Refsrather thanFixesdeliberately: #8184 is an umbrella feature issue with seven separately implementable milestones and this PR delivers only the first. Merging it must not close the umbrella. The milestone plan (M0 to M6) with dependencies and rough sizes is in section 15.2.Related complementary work, intentionally not linked with
Fixessince none is a sub-task of this change: #8150 (bridge aggregation budgets and end-to-end cancellation), #8171 (KubernetesGRPCRoute/BackendTLSPolicy), #8207 (selector client leases and bounded retired channel generations), and apache/shenyu-website#1172 (documentation-site side of thegrpc-httpnaming clarification; nothing here closes it).What the note decides
doExecutebound toServerWebExchange, errors emitted as JSON bodies,MessageWriter.onNextaggregating into a list untilonCompleted,Mono.fromFuture(result.thenApply(...))so cancellation never reachesClientCall.cancel, identity/routing travelling through gRPCContextThreadLocals, and the JSON-envelope contract with theJSON-suffixed service name. §2.7 lists what is reusable (config models, sync channels,PluginDataHandler, theBootstrapServerpattern, namespace/discovery, load-balancer SPI).grpcProxy; the existinggrpcidentifier, enum order, registration RPC type, starter coordinates, selector/rule/metadata bindings and JSON-envelope wire contract stay unchanged;grpc-httpis a display name only. No canonical rename, no implicit database migration.MqttPluginDataHandler+BootstrapServerownership pattern, extended with drain. Configuration is split into restart-class (port, TLS/ALPN, executor sizing, transport limits) and snapshot-class (selectors, rules, method registry, upstreams, policies, limits); snapshot-class changes never touch the listener, so an unrelated selector edit cannot sever long-lived streams.CompletableFuturedependent-stage cancellation as a release mechanism.Notes on accuracy
Every code reference was verified against
masterata87a3613f. Three findings the issue text does not cover are recorded in the note:MqttBootstrapServer.shutdown()is immediate (closes the bound channel,shutdownGracefully()on both event loop groups). Correct for MQTT, insufficient for long-lived gRPC streams — hence the restart-class/snapshot-class split and drain deadline in §6.3.db/upgradecarries-h2,-mysql,-ob,-og,-oracle,-pg, and the H2 fresh-install schema lives inshenyu-admin/src/main/resources/sql-script/h2/schema.sql, not underdb/init(which has noob/ogtree). §5.1/§5.4 list the exact files; §17 records the open question about the ob/og fresh-install path.db/upgrade/native-sql-matrix.md, thenative-sql-matrixgate runs five native database jobs, each executing both the upgrade flow from the pinnedv2.7.1schema and the fresh-install flow, and skipped applicable jobs fail the gate. §5.4 flags this as M4 budget.§9.3 is explicit that at
a87a3613fUpstreamCircuitBreakerhas no local-reject classification, and that the marker-type approach comes from #8189, which is pending rather than merged. Nothing here assumes that PR has landed.Type of change
How was this tested
Documentation-only; no code path, configuration default or schema is affected, so no module build or test run applies. Verification performed instead:
mastera87a3613f(paths, method names, enum orders, SQL dialect layout, CI gate description)docs/*.mdconvention, plus theStatus:line used bydocs/plugin-graph-orchestration.mdFixeslinkage that could close [Feature][gRPC] Add a dedicated native grpc-proxy plugin with streaming and interceptor governance #8184 or any related issue prematurelyChecklist
.licenserc.yamlexcludes**/*.mdand**/docs/**from RAT; header follows repository convention)