Can Live Code or Hot Reload support zero-downtime updates for a Delphi service that accesses a database?
0 reputation · 07 Feb 2020, 19:58 UTC
0 reputation · 07 Feb 2020, 19:58 UTC
We need to migrate a small Delphi service that performs database operations without service interruption.
The service is built with RAD Studio 11 or newer and runs as a Windows service with a local SQL Server database. Documented runtime update mechanisms are Live Code, limited to console-style apps, and Hot Reload, which requires special debug mode and is described for Windows desktop apps. It is unclear if either feature can update database-access code in a running service.
35275 reputation · 07 Feb 2020, 23:28 UTC
Live Code can, under narrow conditions, patch method bodies in a running Delphi service — including database-access code — without a process restart. Hot Reload cannot help you at all: it targets VCL/FMX GUI applications that run a Windows message loop, which a service does not have. Neither feature, however, gives you true zero-downtime deployment in the production sense.
Confirmed by the documented design: Hot Reload requires a debug-mode desktop application with a UI message loop. A Windows service has no message loop, so Hot Reload simply never triggers — enabling it has no effect, and any code change still requires a service restart. This answers your second question directly: no, Hot Reload does not support non-UI modules in a service.
Likely, based on documented Live Code behavior: Live Code works when the process runs under the RAD Studio debugger with Live Code enabled and the binary is compiled with debug information. It patches method bodies only. It cannot change class declarations, field layouts, or interfaces, and it cannot safely update objects that are already instantiated. For a service, that means attaching the debugger to the running service process — which is a debugging scenario, not a production update mechanism.
Changing a SQL string, adjusting a parameter, or tweaking business logic inside a method body is the kind of edit Live Code can apply. Changes that alter class structure, add fields, or touch code currently executing inside an open transaction will be rejected by the IDE or leave the service inconsistent. Applying a patch mid-transaction risks partial updates, so the service should be quiesced first — which already contradicts "zero downtime."
Tools → Options → Debugger → Live Code, then attach the debugger to the service process.If the IDE rejects the patch, the edit touched something outside a method body — that is your boundary.
Treat Live Code as a debugging aid for a staging service, not as an update pipeline. For genuine zero-downtime migration of a production Windows service against SQL Server, use an operational pattern instead: run two service instances behind a failover mechanism, drain connections on one, update it, verify, then switch traffic back. Database schema changes should be made backward-compatible (additive columns, versioned stored procedures) so old and new binaries can coexist during the switchover.
One detail that would change this recommendation: whether your service hosts any listener (HTTP, named pipes, MSMQ) that can be drained gracefully. If it does, the two-instance approach is straightforward; if it polls the database directly, you will need a lease/locking table so only one instance processes work during the cutover.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.