Production Rollout
This runbook orders code, indexes, one-time historical data, and ongoing synchronization for production. See Production Data Migration for Job scenarios and Data Tasks API Reference for every parameter.
Capability Boundaries
monSQLize provides:
ensureIndexes(),ensureModelIndexes(), and collection index APIs.dataTasksfor bounded one-time data and index releases.- Change Stream sync for asynchronous CDC after the initial backfill.
It does not replace full database import/export, database-level recovery, or an exactly-once data pipeline. Establish a database restore point before the release.
Release Sequence
- Create a database backup or managed restore point.
- Deploy the production service with
autoIndex: false. - Dry-run Model indexes, resolve conflicts, then create missing indexes.
- Run
dataTasks.preview(job)when the release needs business data or non-Model indexes. - Review counts, samples, index states, backup estimates, and approval expiry.
- Run
dataTasks.apply()with the approval from that preview. - Validate production read paths; continue only for a passed result.
- Start Change Stream sync only when ongoing updates are required.
- Review sync status, slow queries, errors, and representative data.
- Switch traffic after every gate is green.
Index Rollout and autoIndex
autoIndex: true reads existing indexes after runtime connection, skips existing definitions, and creates missing indexes. It is not a production release gate. Startup cannot replace explicit dry-run, conflict review, unique-index duplicate checks, a maintenance window for heavy builds, or rollback decisions.
Keep automatic index creation disabled in a long-running production service:
ensureModelIndexes() and ModelInstance.ensureIndexes() compare declarations with listIndexes() results first. Execution creates only missing indexes and never drops, renames, or rebuilds conflicts automatically.
For non-Model collections, declare release indexes in dataTasks or use collection APIs directly:
Index gates:
- Check production duplicates before creating a unique index.
- Schedule large index builds in a controlled maintenance window.
- Record current indexes and query impact before destructive index work.
- Recheck slow queries and representative
explain()output after traffic moves.
One-Time Data Migration
Use the same DataTaskJob for the complete one-time release:
Operators should preserve the preview output, apply result, and backup.manifestPath. Any change to source, target, indexes, or Job requires a fresh preview and approval.
When apply returns partial or failed:
- Stop traffic rollout and assume side effects may exist.
- Preserve errors, manifest, and current target state.
- Run
previewRestore()to determine whether strict recovery is safe. - Review restore actions before
restore(); never skip restore preview.
See Production Data Migration for complete scenarios.
Change Stream After Backfill
Change Stream sync handles ongoing CDC, backup databases, projections, cache invalidation, and other asynchronous targets. It does not replace the initial historical backfill.
Operational boundaries:
- MongoDB must be a replica set.
- Delivery is at-least-once, not exactly-once.
- Custom targets should deduplicate by change event
_id. - Monitor
getSyncStats().isRunning,errorCount,lastError, target errors, and token save errors. - Repair or fully compare the gap when a resume token is lost.
Traffic Switch Checklist
Before traffic moves:
npm run release:preflighthas passed.- The database restore point and affected-scope backup are accessible.
- Model index dry-run has no conflicts; missing indexes are handled or explicitly deferred.
- dataTasks passed, and counts and samples match the requirement.
- Indexes required by production queries are ready.
- When CDC is needed, sync stats are healthy and resume tokens are durable.
- Slow-query and application logs contain no new blocker.
- Rollback owner, commands, manifest, and stop conditions are explicit.
After traffic moves:
- Compare source and target counts and samples for critical collections.
- Verify critical records through old and new read paths.
- Watch synchronization delay, errors, and slow queries.
- Use
explain()on representative queries when latency changes. - Preserve the old restore point and dataTasks manifest until the release window closes.