microsoft / microsoft/vscode-documentdb
Investigation: can the legacy v1/v2 storage-wrapping code be removed based on telemetry?
@tnaum-ms is already working on this.
Since Jun 3, 2026.
- Dominant language
- TypeScript
- Stars
- 31
- Forks
- 22
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 21
Description
Background
PR #726 added a per-version census of stored connection items to the connectionStorage.stats activation telemetry event so we can answer one concrete question: how many real installs still carry pre-v3 storage records, and is it safe to delete the legacy read-time wrapping code?
The wrapping code in question lives in src/services/connectionStorageService.ts:
fromStorageItem— switch onitem.versionwith cases for'3.0','2.0', anddefault(v1, no version field).wrapV1AsV2— in-memory upgrade of v1 records to the v2 shape.wrapV2AsCurrent— in-memory upgrade of v2 records to the current shape.convertV2ToConnectionItem— used only on the v2 branch.
Today this runs on every read of every connection item. It is correct but it is dead weight once the installed base no longer holds any v1/v2 records.
What telemetry to look at
Event: connectionStorage.stats (fires once per activation, after cleanup).
Aggregate counters (across both Clusters and Emulators zones):
v1Items,v2Items,v3Items,unknownVersionItemshasLegacyItems— boolean property,'true'iffv1Items + v2Items > 0.
Per-zone counters:
clusters_v1Items,clusters_v2Items,clusters_v3Items,clusters_unknownVersionItemsemulators_v1Items,emulators_v2Items,emulators_v3Items,emulators_unknownVersionItems
Supporting signal on resolvePostMigrationErrors:
previousCleanupVersion— shows installs crossing the legacy'0.8.1'marker → integer counter boundary (added in the same PR).
Questions to answer
- What fraction of unique installs report
hasLegacyItems = 'true'over the most recent full release window? - What is the absolute count of v1 vs v2 items? (v2 is younger than v1, so removal of v1 may unblock first.)
- Is the legacy population shrinking release-over-release? Plot the trend.
- Are there outlier installs holding a large number of legacy items? (a few power users may matter more than the percentage suggests).
- Any
unknownVersionItems > 0reports? Those would indicate either future-format records or corruption and are worth flagging separately.
Decision criteria
- Remove v1 wrapping (
wrapV1AsV2, default branch infromStorageItem) when:v1Items = 0across two consecutive release windows, AND- no install reports
v1Items > 0in the most recent 30 days.
- Remove v2 wrapping (
wrapV2AsCurrent,convertV2ToConnectionItem,'2.0'branch) when the same criteria hold forv2Items. - Defer removal as long as
hasLegacyItems = 'true'for any non-trivial cohort; document the next check-in date.
Tasks
- Pull
connectionStorage.statsdata from telemetry for the current and previous release windows. - Quantify
v1Items/v2Itemspopulations (unique installs, absolute counts, distributions). - Decide per-format whether removal is safe now, in a later milestone, or still gated.
- If removal is approved, file a follow-up PR deleting
wrapV1AsV2/wrapV2AsCurrentand the corresponding branches infromStorageItem. Also drop matching tests. - If removal is deferred, file a follow-up reminder issue for the next milestone with the deferral rationale.
Out of scope
- Forced on-disk migration of legacy records — explicitly avoided in PR #726 (read-time wrapping is intentional). Only the read-side wrapping code is on the chopping block.
- The
STORAGE_CLEANUP_VERSIONinteger counter is a separate marker and unrelated to whether wrapping can be removed.
References
- PR #726 — feat: per-version item census in stats telemetry (e7f21690b63e7825937ed5efd8f16b3da2cdc21d)
- PR #726 — fix: replace cleanup-schema marker with integer counter (12f5163cf6b5f6fa7cbbf8a903facc5f7f34fc48)
- Local design notes:
docs/ai-and-plans/PRs/726-storage-load-optimization/
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.