DEV Community

Hayim Romanovsky
Hayim Romanovsky

Posted on Originally published at migrationparity.com

CDX corruption on network shares: why the 7 a.m. rebuild never ends

Originally published at migrationparity.com.

There is a particular kind of phone call that always comes a few minutes after
seven in the morning. The night shift closed fine, the first clerk of the day
opened the order screen, and the application threw something cryptic — a seek
that lands on the wrong customer, a "record not found" for an order everyone can
see in the grid, or the engine just giving up mid-skip. The fix everyone knows:
get all users out, run the reindex, wait, start the day twenty minutes late.
At one plant I worked with, the key sequence for that ritual lived on a
laminated card taped to the side of a monitor. It had been there so long the
tape had yellowed.

The rebuild works every time. That's exactly the problem — it works, so nobody
asks why the index keeps dying.

What a CDX actually is, and why sharing it is brave

A compound index file is a forest of B-trees, one per tag, each page full of
keys and record pointers, updated in place every time any workstation inserts or
changes a row. In the classic deployment — DBF and CDX on a file share, fifteen
PCs opening them directly — every one of those workstations is a co-author of
the same tree structure, coordinating through nothing but byte-range locks.

That design survives on good days. It corrupts on the bad ones, and the bad ones
come from a short list:

  • a workstation crashes, loses power or drops off the Wi-Fi between writing a data row and updating the tag pages — the tree now disagrees with the table;
  • SMB client-side caching (oplocks and their modern descendants) lets one machine work on a cached copy of index pages while another writes the real ones — the protocol has gotten safer over the decades, but "safer" is doing a lot of work in that sentence when antivirus, backup agents and network hiccups join in;
  • two tools open the same table with different index assumptions — the application maintains the CDX, someone's hand-written utility updates rows without it, and every row it touches silently falls out of the tags.

Note what's not on the list: the DBF itself. The data file usually survives.
It's the tree that rots, which is why a rebuild "fixes" everything — it regrows
the tree from the surviving data.

The treadmill, and the trap inside it

A nightly or morning reindex treats the symptom and resets the clock, nothing
more. The next crash or cache hiccup starts the rot again, and the interval
between rebuilds quietly becomes your data-integrity budget. Worse, rebuilds
hide the real failure: an index that silently drops rows doesn't throw errors
— orders stop appearing in searches while remaining in the file, and nobody
rebuilds anything because nothing looks broken.

One more trap waits inside the ritual itself. After thirty years, does anyone
still know every tag's key expression? I've seen a rebuild script carry a
mis-typed key for years — one tag subtly shorter than the application expected
— because the person who wrote it transcribed the expression by hand from a
screen. If the application can't rebuild its own indexes, the tag definitions
belong in a maintained, versioned list that a script reads, not in muscle
memory. Our DBF Analyzer reads the CDX dependencies of
a table in the browser, which is a decent way to inventory what you actually
have before trusting any rebuild script.

The three real exits

Move the index owner off the share. This is what client-server xBase
engines were invented for: one server process owns the DBF and CDX, clients
send requests, workstation crashes stop mattering. It's the lowest-disruption
cure and it genuinely works — the catch in 2026 is that the best-known engine
for it, SAP's Advantage Database Server, is
past its end of life, so you'd be
adopting an orphan. The compatible open-source reimplementation exists; in my
benchmarks its value is licensing, not speed.

Mirror into SQL and move the readers first. Keep the legacy app writing
DBF, replicate continuously into a real database, point reports and lookups at
the mirror. Index corruption can no longer lose a sale — the mirror re-syncs —
and you've built the first half of a migration while solving today's outage.

Migrate. The full move, done in slices with
parity testing so thirty
years of behavior survives the trip. The 7 a.m. ritual simply ceases to exist;
there is no shared tree to rot.

What doesn't belong on the list is the fourth option everyone actually chooses:
keep rebuilding and hope. Hope has no SLA.

The laminated card, by the way, is still taped to that monitor. But the last
time anyone needed it was the week before the index moved off the share.

Not sure which exit fits your system? That sizing is what our
Advantage Database migration service
and the fixed-price assessment are for — inventory first, decision second.

Top comments (0)