Files
documentdb/pg_documentdb_gw
Juan Carlos Aguilera Mendez e640ba76a7 Merged PR 1689393: Introduce a mechanism to swith between C# and Rust gateways at runtime
### Does this PR have any customer impact?

### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)

### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)

### Are you introducing any new config? If yes, do you have tests with and without them being set?

### ChangeLog (Refer [Template](../oss/CHANGELOG.md))

### Description

This change allows us to swap between C# and Rust gateways by setting the pgmongo.use_rust_native_gateway GUC on and off without depending on Flex "outside" restarts and trigger the restart at runtime.

We read the value of the GUC and if it doesn't match the running gateway, we gracefully shut it down. Upon restart by Docker, C# flow will be executed and StartupHost.sh will be executed. Since the GUC, pgmongo.use_rust_native_gateway, will also be set in a config file, and that will mandate the gateway to actually start up.

This change was validated against a dev cluster by setting the GUC on and off

----
#### AI description  (iteration 1)
#### PR Classification
This pull request introduces a new mechanism for runtime gateway switching, enabling a graceful shutdown of the C# gateway to transition to a Rust gateway.

#### PR Summary
The changes implement a unified shutdown mechanism that allows the service to detect a configuration flag for using the Rust native gateway and to trigger a graceful shutdown accordingly.
- **`Compute.Host/HostShutdown.cs`**: Added a new static class that provides a shutdown task and trigger method.
- **`Compute.Host/HostServiceContainer.cs`**: Introduced a configuration check for the "use_rust_native_gateway" flag that triggers shutdown via the new mechanism.
- **`Host.Postgres.Linux/PostgresMongoServiceHost.cs`**: Updated shutdown and signal handling to use the new HostShutdown mechanism, replacing the previous ctrl-break task approach.
<!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
2025-06-13 15:13:47 +08:00
..