Course outline

MariaDB / Advanced: evidence and reliable operations / Lesson 21

Rehearse a compatible schema change

Plan a nullable column addition while accounting for MariaDB version, locks, and application compatibility.

About 22 min read20 worked examples20 practice exercisesContent reviewed
On this page

Lesson goals

  • Explain staged application compatibility.
  • Interpret LOCK=NONE as a requested strategy with documented limits.
  • Verify schema, data, and recovery after a lab change.
  • Plan compatible expansion, bounded backfill and verified constraint enforcement.
  • Assess metadata-lock, replica and recovery evidence for an online DDL rehearsal.

Define the rollout window

Old and new application versions can overlap during a deployment. A nullable column addition can be an expansion step before compatible readers and writers, a controlled backfill, and any later constraint change. The correct sequence depends on the business contract. Inventory reports, jobs, and replication consumers as well as the main service, and record the expected schema and recovery point before changing anything.

Inspect an isolated starting table

The following illustrative SQL creates a synthetic InnoDB table only in a new disposable MariaDB lab. It records two manifest rows and inspects the starting definition. Do not run it on a configured database. A real rehearsal should use representative data size, concurrent transactions, the exact MariaDB branch and storage engine, and an approved backup and stopping procedure.

sql Create the lab table
CREATE TABLE lab_manifest (id INT PRIMARY KEY, status VARCHAR(12) NOT NULL) ENGINE=InnoDB;
INSERT INTO lab_manifest VALUES (1, 'new'), (2, 'ready');
SHOW CREATE TABLE lab_manifest;

The starting fixture has id and status columns and two rows. SHOW CREATE TABLE output depends on the server and is not asserted. The public course does not execute this SQL.

Request a locking strategy

The next statement requests LOCK=NONE for an added nullable column. MariaDB’s supported algorithms and concurrency behavior depend on the operation, engine, and server version; an unsupported explicit strategy can fail. Online DDL can still require metadata locks and consume resources. Review the target documentation and rehearse with representative workload rather than interpreting the clause as a promise of zero impact.

sql Add and inspect the lab column
ALTER TABLE lab_manifest ADD COLUMN source_code VARCHAR(20) NULL, LOCK=NONE;
SHOW CREATE TABLE lab_manifest;
SELECT id, status, source_code FROM lab_manifest ORDER BY id;

If the statement succeeds under the lab’s conditions, existing rows read NULL for source_code. Inspect the actual definition and rows; the example does not claim a server result or duration.

Observe transaction and lock boundaries

A transaction that has used a table can retain a metadata lock until it ends, delaying a schema operation. Capture authorized wait and owner evidence and coordinate with the responsible application before resolving a blocker. Do not terminate arbitrary sessions or assume a DDL change can be undone like ordinary DML. Document a tested forward-repair or restore procedure and the conditions for stopping the rollout.

Verify each stage

After the change, compare the actual table definition and row counts with the expected contract. Test both old and new application versions, representative reads and writes, and replication progress where relevant. Backfill only through a separately reviewed bounded process, then verify completeness before tightening constraints. Record lock waits, resource use, errors, and recovery evidence; a successful ALTER alone does not demonstrate full application compatibility.

Define a compatibility window

An online schema change is a coordinated application and database rollout, not merely an ALTER statement. Inventory every consumer: old and new application instances, reports, background jobs, importers and administrative tools. Specify what each version reads and writes while both may run. For a new required attribute, a common expand-and-contract pattern begins with a nullable compatible column, deploys readers and writers that tolerate both states, backfills existing rows, verifies completeness and only then considers a stricter constraint. The correct order depends on the actual application contract and must be rehearsed.

A nullable addition can keep old code working only if that code truly tolerates the altered schema. Positional INSERT statements, SELECT * consumers, generated mappings and deployment assumptions may behave differently from explicit column lists. Test both old and new versions against a representative isolated copy. Record the starting definition, row counts, versions, table size, long transactions, replication topology and recovery point before selecting an operation.

Treat an algorithm request as a constraint

MariaDB InnoDB offers operation-specific online DDL algorithms and restrictions. An explicit ALGORITHM=INSTANT request asks the server to use that algorithm for a particular supported change; if the actual table and operation cannot use it, the statement can fail rather than silently providing an unsupported assumption. Review the MariaDB documentation for the exact operation and table conditions, and test the deployed patch level and schema. Do not extrapolate one successful column addition to every ALTER operation.

Even an instant metadata change can need metadata locks and can wait behind a long transaction. It also does not prove zero application latency, replica impact or operational risk. Establish a deadline and stopping conditions, observe lock and resource evidence through authorized channels and rehearse concurrent traffic. A hypothetical success for the lesson fixture makes its existing rows read NULL for the added nullable source_code; it is not a claim that a live server executed the DDL.

Backfill without losing new writes

Adding a nullable column is only the expansion stage when the final business rule requires a value. Deploy compatible code that writes the new field before or during a controlled backfill according to the rollout contract. Backfill in bounded batches with observable progress, a stable key range and a documented retry policy. Avoid overwriting a newer value written by the application: a predicate such as source_code IS NULL can protect already populated rows when that matches the business rule, but concurrent behavior still requires testing.

After backfill, count missing and invalid values and verify representative row mappings, not only the number of updates. Ensure all active writers satisfy the new rule so NULL cannot reappear between validation and enforcement. If one row remains NULL, imposing NOT NULL is premature until the cause is resolved. Design the stricter change, its locking and recovery separately; a successful first ALTER does not prove that the later constraint will succeed or be online under the same conditions.

Plan metadata locks and recovery

DDL can require metadata locks even when row data need not be rebuilt. A long transaction that accessed a table may retain metadata protection after its SELECT returns, delaying the ALTER and potentially affecting later requests. Inspect authorized lock evidence and transaction age during rehearsal, and define who can resolve a blocker under the established procedure. Increasing a timeout does not shorten the blocking transaction. Set a stop threshold before rollout and monitor application errors, resource pressure and replica progress.

MariaDB DDL has transaction behavior distinct from ordinary rollbackable DML. Do not assume a surrounding ROLLBACK will undo an ALTER TABLE. Prepare a tested forward repair, reverse migration where appropriate, or restore strategy, and understand what data written by new code would be lost or transformed. Keep backups independent and verify restore readiness. The public examples do not alter any configured database or provide an operational deployment command.

Rehearse every stage and decision

A successful ALTER is one observation, not complete rollout evidence. After each stage inspect the actual schema definition, expected row counts, representative values and constraints. Exercise old and new readers and writers, including background jobs; test a long transaction, a failed algorithm request, a partially completed backfill and a retry. Measure duration, metadata-lock waits, application error rate and replica progress on representative synthetic data. Verify that the rollout remains within its predeclared stop criteria.

Record the exact server version, table definition, data distribution, concurrent workload and recovery procedure so the result is reproducible. Rehearse the forward repair or restore and test that application behavior remains correct after it. Compare counts and selected identities rather than relying on one aggregate. SQL and timelines below are non-runnable MariaDB illustrations, using the two-row lab fixture or explicitly declared synthetic scenarios; no schema, data or server was modified.

20 worked examples

1. Starting definition

Problem: What columns and rows does the synthetic starting table contain?

  1. The declared table contains id and status before the column addition.
  2. The two inserted rows have identifiers 1 and 2 with the stated statuses.
sql Starting definition
CREATE TABLE lab_migration_orders (id INT PRIMARY KEY, status VARCHAR(12) NOT NULL) ENGINE=InnoDB;
INSERT INTO lab_migration_orders VALUES (1, 'new'), (2, 'paid');
SELECT id, status FROM lab_migration_orders ORDER BY id;
Expected output
1 | new
2 | paid

Illustrative MariaDB SQL or labeled synthetic migration scenario; outcomes are conditional and reasoned, and no schema was changed locally.

Expected result: Two rows with id and status.

Why this result follows: A documented baseline makes later schema and data comparisons meaningful. This follows the stated schema and migration assumptions.

2. Nullable addition

Problem: If the declared nullable column addition succeeds, what do existing rows show?

  1. The new column permits NULL and no value is supplied for existing rows.
  2. Under the stated successful addition both preexisting rows read NULL for source_code.
sql Nullable addition
-- Independent disposable fixture with rows 1/new and 2/paid.
ALTER TABLE lab_migration_orders ADD COLUMN source_code VARCHAR(20) NULL, ALGORITHM=INSTANT;
SELECT id, source_code FROM lab_migration_orders ORDER BY id;
Expected output
1 | NULL
2 | NULL

Illustrative MariaDB SQL or labeled synthetic migration scenario; outcomes are conditional and reasoned, and no schema was changed locally.

Expected result: Both existing rows show NULL.

Why this result follows: A nullable addition provides a compatible interim representation for absent old values.

3. Algorithm unsupported

Problem: What should a rehearsal conclude if an explicit INSTANT request is unsupported?

  1. The explicit algorithm is a requirement for this statement rather than a guaranteed capability.
  2. An unsupported operation cannot be counted as a successful instant change.
sql Algorithm unsupported
-- Synthetic outcome: ALTER TABLE ... ALGORITHM=INSTANT is rejected as unsupported for this table.
-- No alternative algorithm was requested.
Expected output
The requested operation failed; reassess the change and supported options.

Illustrative MariaDB SQL or labeled synthetic migration scenario; outcomes are conditional and reasoned, and no schema was changed locally.

Expected result: Stop and review the actual table and server restrictions.

Why this result follows: An explicit algorithm request constrains execution but does not prove support. This follows the stated schema and migration assumptions.

4. Metadata blocker

Problem: Why might an instant column addition wait in a synthetic two-session rehearsal?

  1. A accessed the table within a transaction that remains open.
  2. DDL may need a metadata lock even when its requested algorithm avoids a table rebuild.
sql Metadata blocker
-- A: START TRANSACTION; SELECT id FROM lab_migration_orders WHERE id=1; -- remains open
-- B: ALTER TABLE lab_migration_orders ADD COLUMN source_code VARCHAR(20) NULL, ALGORITHM=INSTANT; -- may wait
-- A: COMMIT;
Expected output
B may wait for metadata-lock access until A ends.

Illustrative MariaDB SQL or labeled synthetic migration scenario; outcomes are conditional and reasoned, and no schema was changed locally.

Expected result: Investigate the blocker and apply the predeclared stop policy.

Why this result follows: An online or instant algorithm does not eliminate metadata-lock requirements. This follows the stated schema and migration assumptions.

5. Old explicit insert

Problem: What happens in the staged schema when old code names only the original columns?

  1. The explicit insert supplies the required original id and status columns.
  2. The newly added nullable column receives NULL when omitted in this scenario.
sql Old explicit insert
-- Assumes source_code VARCHAR(20) NULL has been added successfully.
INSERT INTO lab_migration_orders (id, status) VALUES (3, 'new');
SELECT id, status, source_code FROM lab_migration_orders WHERE id=3;
Expected output
3 | new | NULL

Illustrative MariaDB SQL or labeled synthetic migration scenario; outcomes are conditional and reasoned, and no schema was changed locally.

Expected result: 3/new/NULL.

Why this result follows: Explicit column lists can support a compatible expansion when the new column permits omission.

6. Positional insert risk

Problem: Why must an old positional INSERT be tested after a column is added?

  1. The old statement depends on the table’s complete column layout.
  2. Adding source_code changes that layout while the statement still supplies two values.
sql Positional insert risk
-- Old consumer statement before expansion:
INSERT INTO lab_migration_orders VALUES (3, 'new');
-- Later schema has id, status, source_code.
Expected output
The old two-value positional insert no longer matches the three-column layout.

Illustrative MariaDB SQL or labeled synthetic migration scenario; outcomes are conditional and reasoned, and no schema was changed locally.

Expected result: The consumer requires a compatible explicit-column change.

Why this result follows: Schema compatibility includes client statement shape, not only whether the new column is nullable.

7. New writer

Problem: What value does a compatible new writer store after expansion?

  1. The new writer explicitly names and supplies source_code.
  2. The value web fits the declared VARCHAR(20) column in this scenario.
sql New writer
-- Assumes nullable source_code exists.
INSERT INTO lab_migration_orders (id, status, source_code) VALUES (3, 'new', 'web');
SELECT source_code FROM lab_migration_orders WHERE id=3;
Expected output
web

Illustrative MariaDB SQL or labeled synthetic migration scenario; outcomes are conditional and reasoned, and no schema was changed locally.

Expected result: web.

Why this result follows: A new writer can populate the expanded representation without requiring old rows to be complete.

8. Backfill first batch

Problem: What is the result of filling the first missing synthetic row?

  1. The predicate selects only id 1 while its source_code is missing.
  2. The update fills that row and leaves id 2 for a later batch.
sql Backfill first batch
-- Initial expanded rows: (1,new,NULL), (2,paid,NULL).
UPDATE lab_migration_orders SET source_code='legacy' WHERE id=1 AND source_code IS NULL;
SELECT id, source_code FROM lab_migration_orders ORDER BY id;
Expected output
1 | legacy
2 | NULL

Illustrative MariaDB SQL or labeled synthetic migration scenario; outcomes are conditional and reasoned, and no schema was changed locally.

Expected result: One row filled; one remains NULL.

Why this result follows: A bounded key predicate makes backfill progress observable and limits the write scope.

9. Protect new value

Problem: What happens when a backfill encounters a value already written by new code?

  1. The current value api is not NULL.
  2. The backfill predicate therefore does not match the already populated row.
sql Protect new value
-- Synthetic current row: id 2, source_code = 'api'.
UPDATE lab_migration_orders SET source_code='legacy' WHERE id=2 AND source_code IS NULL;
Expected output
0 rows changed; source_code remains api.

Illustrative MariaDB SQL or labeled synthetic migration scenario; outcomes are conditional and reasoned, and no schema was changed locally.

Expected result: The new value is preserved.

Why this result follows: A missing-only predicate avoids overwriting this newer value under the stated rule.

10. Incomplete backfill

Problem: Can NOT NULL be considered ready while one synthetic row remains missing?

  1. One row still lacks the value required by the proposed final contract.
  2. The missing row must be resolved and active writers checked before tightening.
sql Incomplete backfill
-- Synthetic validation: 100 rows total; 99 valid source_code values; 1 NULL.
SELECT COUNT(*) AS remaining FROM lab_migration_orders WHERE source_code IS NULL;
Expected output
1

Illustrative MariaDB SQL or labeled synthetic migration scenario; outcomes are conditional and reasoned, and no schema was changed locally.

Expected result: The column is not ready for NOT NULL.

Why this result follows: Completeness is a prerequisite to enforcing a required field on existing data.

11. Concurrent old writer

Problem: What risk remains if old code can still insert NULL after validation?

  1. The old writer omits the nullable source_code field.
  2. The earlier zero count describes only the state at validation time.
text Concurrent old writer
-- Synthetic sequence: validation finds 0 NULL rows.
-- An old writer then inserts id 4 without source_code.
-- A later constraint change is attempted.
Expected output
A new missing value can appear between validation and enforcement.

Illustrative MariaDB SQL or labeled synthetic migration scenario; outcomes are conditional and reasoned, and no schema was changed locally.

Expected result: Make active writers compatible and recheck before tightening.

Why this result follows: A one-time completeness count does not control future concurrent writes. This follows the stated schema and migration assumptions.

12. Bad mapping

Problem: Why is a zero NULL count insufficient to prove a backfill mapping correct?

  1. The completeness count checks absence, not whether values match their source facts.
  2. Both non-NULL values can be wrong while the count still reports zero.
text Bad mapping
-- Synthetic rows: id 1 should map to web; id 2 should map to api.
-- Backfill writes legacy to both, leaving zero NULL values.
Expected output
Both rows are populated, but their values violate the intended mapping.

Illustrative MariaDB SQL or labeled synthetic migration scenario; outcomes are conditional and reasoned, and no schema was changed locally.

Expected result: Verify representative mappings and domain validity.

Why this result follows: Completeness and correctness are separate validation properties. This follows the stated schema and migration assumptions.

13. Repeated batch

Problem: What happens when a completed missing-only batch is run again?

  1. The row no longer meets source_code IS NULL after the first successful batch.
  2. Repeating the same predicate leaves the existing value unchanged.
sql Repeated batch
-- Synthetic current row: id 1, source_code = 'legacy'.
UPDATE lab_migration_orders SET source_code='legacy' WHERE id=1 AND source_code IS NULL;
Expected output
0 rows changed; legacy remains.

Illustrative MariaDB SQL or labeled synthetic migration scenario; outcomes are conditional and reasoned, and no schema was changed locally.

Expected result: The repeated batch changes zero rows.

Why this result follows: A carefully scoped missing-only update can be safely repeatable for this stated mapping.

14. Rollback misconception

Problem: Does a surrounding ROLLBACK generally undo the schema change?

  1. MariaDB DDL such as ALTER TABLE has implicit-commit behavior.
  2. A data-transaction rollback is not a tested reverse migration for the schema.
sql Rollback misconception
START TRANSACTION;
ALTER TABLE lab_migration_orders ADD COLUMN source_code VARCHAR(20) NULL;
ROLLBACK;
Expected output
The ALTER is not generally undone by the rollback.

Illustrative MariaDB SQL or labeled synthetic migration scenario; outcomes are conditional and reasoned, and no schema was changed locally.

Expected result: Use the documented forward repair or recovery procedure.

Why this result follows: DDL transaction behavior differs from ordinary rollbackable DML. This follows the stated schema and migration assumptions.

15. Replica progress

Problem: Why should a synthetic rollout observe replicas after source DDL completes?

  1. DDL must reach and be applied by the replica in the stated topology.
  2. New code routed there before application may encounter an incompatible schema.
sql Replica progress
-- Synthetic topology: source ALTER completes; replica apply is delayed.
-- New application code can read from the replica.
Expected output
The replica may not yet expose the new schema to readers.

Illustrative MariaDB SQL or labeled synthetic migration scenario; outcomes are conditional and reasoned, and no schema was changed locally.

Expected result: Monitor replica progress and gate routing or rollout appropriately.

Why this result follows: Source completion and replica readiness are separate observations. This follows the stated schema and migration assumptions.

16. Stop threshold

Problem: What should happen when a synthetic metadata-lock wait exceeds the rehearsal limit?

  1. The observed wait exceeds the five-second limit by three seconds.
  2. Continuing would violate the decision threshold established before the change.
text Stop threshold
-- Rehearsal policy: stop if metadata-lock wait exceeds 5 seconds.
-- Observed synthetic wait: 8 seconds.
Expected output
Stop according to the predeclared policy and investigate the blocker.

Illustrative MariaDB SQL or labeled synthetic migration scenario; outcomes are conditional and reasoned, and no schema was changed locally.

Expected result: Stop and follow the authorized procedure.

Why this result follows: A predeclared threshold turns monitoring evidence into a controlled decision. This follows the stated schema and migration assumptions.

17. Old and new readers

Problem: What should a compatible reader do with existing NULL source_code values?

  1. Existing rows have not necessarily been backfilled during expansion.
  2. A reader that assumes a non-NULL code immediately can fail before backfill completes.
text Old and new readers
-- Synthetic expanded row: id 1, status new, source_code NULL.
-- New reader supports both old and populated representations.
Expected output
Handle NULL according to the documented compatibility policy.

Illustrative MariaDB SQL or labeled synthetic migration scenario; outcomes are conditional and reasoned, and no schema was changed locally.

Expected result: Read the row without inventing an unverified code.

Why this result follows: The compatibility window requires consumers to tolerate both data states. This follows the stated schema and migration assumptions.

18. Index and resource evidence

Problem: What measurements matter when a backfill touches a large indexed table?

  1. A backfill can consume write, index-maintenance and replication resources.
  2. Rows changed alone do not reveal application latency or replica impact.
text Index and resource evidence
-- Synthetic rehearsal records batch duration, rows changed, write latency, replica progress and errors.
Expected output
Compare batch throughput and collateral workload effects with the rollout limits.

Illustrative MariaDB SQL or labeled synthetic migration scenario; outcomes are conditional and reasoned, and no schema was changed locally.

Expected result: Record progress and resource effects for each bounded batch.

Why this result follows: Operational readiness includes the wider workload, not only a successful update count.

19. Counts and identity

Problem: Can two restored migration rows preserve count while one id is wrong?

  1. The row count remains two in both the expected and observed sets.
  2. Comparing identities reveals the substitution that the count hides.
sql Counts and identity
-- Expected ids: 1, 2.
-- Synthetic observed ids: 1, 9.
SELECT COUNT(*) FROM lab_migration_orders;
Expected output
Both sets contain two rows, but id 2 is missing and id 9 is unexpected.

Illustrative MariaDB SQL or labeled synthetic migration scenario; outcomes are conditional and reasoned, and no schema was changed locally.

Expected result: Count alone does not establish correct row identity.

Why this result follows: Representative key checks complement aggregate row-count verification. This follows the stated schema and migration assumptions.

20. Recovery rehearsal

Problem: What evidence demonstrates more than a successful ALTER in a synthetic rehearsal?

  1. A successful schema statement does not prove that consumers tolerate both data states.
  2. Backfill, replica readiness and repair each have separate failure paths.
text Recovery rehearsal
-- Rehearsal checklist: schema definition, old/new reads and writes, backfill validation, replica progress, repair test.
Expected output
Verify compatibility and tested recovery as well as the DDL result.

Illustrative MariaDB SQL or labeled synthetic migration scenario; outcomes are conditional and reasoned, and no schema was changed locally.

Expected result: Record all stage results and stop criteria.

Why this result follows: A rollout is a multi-stage contract rather than a single DDL exit status.

Common errors and fixes

An online schema change waits unexpectedly.

Why it happens
A transaction holds a metadata lock needed by the change.
How to fix it
Inspect authorized lock evidence and follow the blocker-resolution procedure.
Prevent it next time
Rehearse with long transactions and monitor waits.

The explicit locking strategy fails.

Why it happens
The operation, engine, or version does not support the requested strategy.
How to fix it
Review target-specific documentation and choose an approved compatible plan.
Prevent it next time
Test the exact schema and server branch before rollout.

An old application version fails after a column change.

Why it happens
The compatibility window was not tested.
How to fix it
Use the documented repair or restore plan.
Prevent it next time
Inventory consumers and test overlapping versions.

20 practice exercises

1. What is source_code for existing lab rows if the ALTER succeeds?

Show hint

Consider the new column’s nullability and the absence of supplied values.

Show worked solution

The added nullable column reads NULL for the two existing rows. Confirm the actual definition and results in the intended isolated environment.

If the nullable addition succeeds as specified, both existing fixture rows read NULL for source_code. Inspect the actual table definition and row values in the disposable lab; the conditional example does not establish a live result.

Check your solution

  • Row 1 reads NULL.
  • Row 2 reads NULL.

2. Does LOCK=NONE guarantee that the change has no operational impact?

Show hint

Separate requested DML concurrency from metadata-lock and workload effects.

Show worked solution

No. Support varies by operation and version, metadata locks may still matter, and resource use and replication impact need testing.

LOCK=NONE does not promise zero operational impact. Support depends on the exact MariaDB version and operation, metadata locks can still delay DDL, and resource and replica effects require a representative rehearsal with stop criteria.

Check your solution

  • Verify LOCK=NONE support for the exact operation.
  • Test metadata waits and resource or replication impact.

3. The two-row fixture receives a nullable source_code column successfully. Predict the existing values.

Show hint

Trace consumer compatibility, DDL conditions, validation and recovery separately.

Show worked solution

Both existing rows read NULL because the new column is nullable and no explicit value was supplied for those rows. Verify the actual definition and row results in the isolated lab. This is a conditional prediction, not evidence of a live ALTER.

Check your solution

  • Row 1 is NULL
  • Row 2 is NULL

4. Explain why ALGORITHM=INSTANT is not a guarantee of zero downtime for a column addition.

Show hint

Trace consumer compatibility, DDL conditions, validation and recovery separately.

Show worked solution

The exact operation and table must support the requested algorithm, and DDL can still wait for metadata locks or affect resources and replicas. Rehearse with representative traffic and long transactions, monitor predeclared limits and prepare a tested recovery path.

Check your solution

  • Support is operation-specific
  • Metadata-lock waits remain possible

5. An old consumer uses INSERT INTO table VALUES with two values. A third column is added. What must be tested?

Show hint

Trace consumer compatibility, DDL conditions, validation and recovery separately.

Show worked solution

The positional statement depends on the full column layout and can fail when the table gains a column. Change and test the consumer to name its intended columns explicitly, and verify that the new nullable column may be omitted. Inventory background jobs as well as the application.

Check your solution

  • Positional insert may fail
  • Test explicit-column consumer

6. A new writer supplies source_code while an old writer omits it. What compatibility behavior is needed?

Show hint

Trace consumer compatibility, DDL conditions, validation and recovery separately.

Show worked solution

The expanded schema and readers must handle both a populated value and NULL during the overlap, according to a documented policy. Test old and new reads and writes before tightening the constraint. Ensure all active writers eventually provide a valid value.

Check your solution

  • Readers tolerate both states
  • Writers become compatible before tightening

7. A backfill updates 200 rows per batch. Why record batch progress and write latency separately?

Show hint

Trace consumer compatibility, DDL conditions, validation and recovery separately.

Show worked solution

Rows updated show progress, but they do not reveal effects on application writes, locks or replicas. Record duration, throughput, write latency, errors and replica progress for each bounded batch. Apply the predeclared stop threshold if operational impact exceeds the agreed limit.

Check your solution

  • Track rows and duration
  • Track write and replica effects

8. A backfill sets source_code only where it is NULL. What does this protect, and what does it not prove?

Show hint

Trace consumer compatibility, DDL conditions, validation and recovery separately.

Show worked solution

The predicate avoids overwriting an already populated value written by new code in the stated design. It does not prove that existing non-NULL values are correct or that every concurrent scenario is safe. Verify mappings and active writer behavior under representative concurrency.

Check your solution

  • Preserve existing non-NULL values
  • Validate mapping and concurrency

9. A validation query finds one NULL in 100 rows. Should the new NOT NULL constraint be enforced immediately?

Show hint

Trace consumer compatibility, DDL conditions, validation and recovery separately.

Show worked solution

No. Resolve the missing row according to the business mapping, verify all other values and ensure active writers cannot reintroduce NULL. Then rehearse the stricter change with its own locking and recovery plan. A successful earlier nullable addition does not prove readiness.

Check your solution

  • One NULL remains
  • Verify writers before tightening

10. A zero NULL count is followed by an old writer inserting NULL. What rollout gap does this reveal?

Show hint

Trace consumer compatibility, DDL conditions, validation and recovery separately.

Show worked solution

The validation was a point-in-time observation while an incompatible writer remained active. Deploy or gate writers so new missing values cannot appear, then revalidate immediately before enforcement under the intended procedure. A count alone cannot guarantee future completeness.

Check your solution

  • Old writer reintroduced NULL
  • Gate writers and revalidate

11. A backfill fills every field but assigns the wrong source to two rows. Why does COUNT WHERE NULL miss it?

Show hint

Trace consumer compatibility, DDL conditions, validation and recovery separately.

Show worked solution

The missing-value count tests only whether a value exists, not whether it is the correct mapped value. Compare representative keys and source facts and validate the allowed domain in addition to counting NULLs. Correct the mapping under a reviewed procedure before enforcing the final contract.

Check your solution

  • Zero NULLs can hide wrong values
  • Verify per-row mappings

12. A transaction reads the table and stays open while ALTER waits. Which lock class should be investigated?

Show hint

Trace consumer compatibility, DDL conditions, validation and recovery separately.

Show worked solution

Investigate metadata locking and the age and ownership of the blocking transaction. A transaction may retain table metadata protection after its SELECT returns, delaying DDL. Follow the authorized blocker-resolution procedure and the predeclared stop threshold; a longer timeout does not release the lock.

Check your solution

  • Investigate metadata lock
  • Inspect blocker transaction age

13. A rehearsal sets a five-second lock-wait stop limit and observes eight seconds. What decision follows?

Show hint

Trace consumer compatibility, DDL conditions, validation and recovery separately.

Show worked solution

The observed wait exceeds the limit by three seconds, so stop according to the established rollout policy and investigate the blocker. Do not redefine the threshold during the incident merely to continue. Record the observation and repair plan before another rehearsal.

Check your solution

  • Eight exceeds five seconds
  • Stop and investigate

14. The source applies DDL but a replica is delayed. Why can new application code still fail?

Show hint

Trace consumer compatibility, DDL conditions, validation and recovery separately.

Show worked solution

A client routed to the replica may reach a schema that has not yet applied the new column. Monitor replica progress and gate rollout or routing according to the documented compatibility plan. Source success alone is not evidence that every read endpoint is ready.

Check your solution

  • Replica may lack the column
  • Gate routing on readiness

15. A developer plans ROLLBACK after ALTER TABLE as the only reversal. Explain the defect.

Show hint

Trace consumer compatibility, DDL conditions, validation and recovery separately.

Show worked solution

MariaDB DDL such as ALTER TABLE has implicit-commit behavior and is not generally undone by a surrounding application ROLLBACK. Prepare and rehearse a forward repair, reviewed reverse migration or restore strategy. Consider data written by new code before choosing a reversal.

Check your solution

  • ROLLBACK is not general DDL undo
  • Test an explicit recovery path

16. The DDL succeeds on two rows in a lab. Why is that insufficient to predict production impact?

Show hint

Trace consumer compatibility, DDL conditions, validation and recovery separately.

Show worked solution

A tiny fixture cannot reproduce table size, metadata-lock contention, concurrent workload, replica lag or resource pressure. Use representative synthetic data and traffic in an isolated rehearsal, record the exact server and schema, and compare measurements with predeclared stop criteria.

Check your solution

  • Two rows do not represent scale
  • Measure locks and workload

17. An ALTER requests INSTANT but the operation is unsupported for the actual table. What should the rollout do?

Show hint

Trace consumer compatibility, DDL conditions, validation and recovery separately.

Show worked solution

Treat the rejected statement as a failed stage and stop to review the operation-specific MariaDB version and table restrictions. Do not assume an unsupported algorithm succeeded or silently substitute another method. Rehearse a reviewed alternative and its lock and recovery implications.

Check your solution

  • Explicit request can fail
  • Review and rehearse an alternative

18. Two expected rows have ids 1 and 2; restored rows have ids 1 and 9. Why is count two insufficient?

Show hint

Trace consumer compatibility, DDL conditions, validation and recovery separately.

Show worked solution

Both datasets contain two rows, so COUNT(*) alone matches despite the missing id 2 and unexpected id 9. Compare selected keys, relationships and representative values in addition to counts. Use known synthetic expectations to identify the substitution.

Check your solution

  • Count remains two
  • Ids differ

19. A rollout plan lists only the ALTER statement. Name two missing categories of evidence.

Show hint

Trace consumer compatibility, DDL conditions, validation and recovery separately.

Show worked solution

It also needs compatibility evidence for old and new consumers and a tested recovery or forward-repair procedure. Record backfill completeness, metadata-lock waits, replica progress and application errors as applicable. A successful DDL statement alone does not demonstrate the full rollout contract.

Check your solution

  • Test consumer compatibility
  • Test recovery and monitoring

20. A migration changes a column used by reports and a background job. Why inventory both consumers?

Show hint

Trace consumer compatibility, DDL conditions, validation and recovery separately.

Show worked solution

Each consumer may use different SQL assumptions, privileges and deployment timing, so an application-only test can miss failures. Document and test reports, jobs, importers and all running application versions during the compatibility window. Coordinate their rollout before enforcing a stricter schema contract.

Check your solution

  • Reports and jobs are consumers
  • Test their version overlap

Key takeaways

  • Stage schema and application changes around a compatibility window.
  • Explicit lock requests have version and operation limits.
  • Verify data, application behavior, and recovery in a representative rehearsal.
  • Nullable expansion is one stage of an application compatibility contract.
  • INSTANT is an algorithm request, not a zero-impact guarantee.
  • DDL needs a tested repair or recovery plan outside ordinary transaction rollback.

Official references