# EXTRA_CF Encoding Upgrade (Two-Phase Rollout)

This repository supports **two EXTRA_CF key encodings** for transaction status records:

- **Legacy**: `raw_key + BigEndian(start_ts.reverse_bits())`
- **New**: `raw_key + BigEndian(!start_ts)` (TiKV-style `encode_u64_desc`)

Reads are **backward-compatible** (they try both encodings).

Current write behavior:
- `encode_extra_txn_status_key` uses the **new** TiKV-style descending encoding.
- Read path remains backward-compatible with both legacy and new encodings.

## Upgrade History

1. **Phase 1 (PR #4464)**: Deployed read-both + write-legacy across all clusters.
2. **Phase 2 (current)**: Write default switched to `encode_extra_txn_status_key_desc`.
   Dual-format read logic preserved for historical data compatibility.

## Build

- `cargo build -p tikv-server`

## Notes

- Switching write default to the new format changes **on-disk key encoding** for
  future `EXTRA_CF` writes.
- Keep the write switch guarded by a cluster-wide rollout check: only switch
  after all TiKV servers run a version that can decode both encodings.
- A later cleanup release can optionally add a migration job to rewrite legacy keys.
