Tomcat Parallel Deployment: Deciding the Old Version's Role During a Schema Migration
0 reputation · 08 May 2024, 09:14 UTC
0 reputation · 08 May 2024, 09:14 UTC
Tomcat's parallel deployment feature lets multiple versions of the same web application run under one context path, using versioned artifact names such as app##001.war and app##002.war. The container routes new requests to the newest version while older versions remain deployed, which is the usual basis for an application-level rollback path.
Tomcat does not manage database schemas, so a migration and its reversal are handled outside the container. If the older version stays active during the migration, it may keep reading and writing rows under assumptions the new schema no longer holds. Stopping it avoids that risk but removes the rollback target and can interrupt sessions.
Session persistence adds a boundary: sessions shared across versions may carry attributes whose shape changed with the schema. Naming and deployment rules vary by Tomcat major version, so confirm them against the target release.
32275 reputation · 08 May 2024, 11:06 UTC
Stop the prior version before applying a destructive schema change. Keep it active only during an additive, expand-phase migration where the old code tolerates new nullable columns or tables. If the migration drops columns, renames tables, or tightens constraints, the old version must not run against the new schema.
Parallel deployment keeps the older versioned WAR deployed so existing sessions continue to be served. New requests are routed only to the highest version number. This is confirmed behavior. The old context is not drained or stopped automatically; it remains a live application that can continue issuing database writes.
The container does not manage database schemas. If the migration is non-backward-compatible, the old version will keep executing SQL shaped for the old schema. That leads to failed statements, silent data corruption, or session deserialization errors. If the migration is purely additive and the old code does not rely on SELECT * or strict schema validation, the old version can remain active through the expand phase.
Shared session attributes must be forward-compatible. New fields should be nullable or ignored by the old version. If object shapes change incompatibly, invalidate sessions or isolate session storage per version. Otherwise, expect ClassCastException or stale reads when the old version deserializes attributes written by the new version.
app##002.war, ensuring it can operate against the current schema during the expand phase. Tomcat routes new requests to it.Parallel deployment naming and session stickiness vary by Tomcat major version. Confirm the exact rules for your target release before relying on automatic routing. In staging, deploy two versioned WARs and apply a destructive migration to check whether the old context logs SQL errors. Use the Tomcat Manager to stop the specific versioned context; confirm the exact parameter syntax for your release before scripting it. Inspect a persisted session after deploying the new version to verify that the old version can still deserialize shared attributes.
Is your schema migration additive (expand) or destructive (contract)? That single fact determines whether the old version can remain active or must be stopped first.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.