Skip to content

fix: Verify SDKs read all three persistent-store tombstone shapes - #484

Merged
jsonbailey merged 1 commit into
v3from
jb/sdk-3174/tombstones-v3
Sep 28, 2026
Merged

jsonbailey merged 1 commit into
v3from
jb/sdk-3174/tombstones-v3

Conversation

@jsonbailey

@jsonbailey jsonbailey commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Ports the persistent-store tombstone-shape tests from v2 (#438) to v3. Jira: SDK-3174.

What the cases cover

A tombstone is the record an SDK writes to a persistent store to mark an item
deleted. Version-based conflict resolution needs it: with no record at all, a
stale out-of-order update would bring the item back.

The store already addresses the record by key -- the Redis hash field, the Consul
key, or the DynamoDB sort key -- so the key inside the JSON body is redundant.
Our SDKs write three different shapes anyway:

shape written by
{"version":N,"deleted":true} (no key) .NET, Java, Node (Redis upsert), Haskell
{"key":"<real key>","version":N,"deleted":true} Python, Ruby, C++, Erlang, Node (init)
full object keyed "$deleted" Go v5+, Relay Proxy, Rust

Any SDK can be pointed at a store a different SDK wrote, so a reader has to
handle all three. Each shape gets two cases:

  1. flags -- a tombstone sits alongside the live flags. The live flags must
    still be readable (one unrecognized record must not spoil the whole
    collection), the deleted flag must be absent from all-flags state, and asking
    for it by key must look identical to asking for a flag that was never there
    (FLAG_NOT_FOUND).
  2. segments -- a flag matches the deleted segment. A deleted segment matches
    nothing, so the flag must serve not-matched. The full-object shape carries
    the evaluation context in included, so a reader that mistakes the tombstone
    for a live segment serves matched instead.

Each case runs for Redis, Consul and DynamoDB.

Why this is a port and not a cherry-pick

v3 restructured this suite, so the wiring from v2 does not apply:

v2 v3
subtree t.Run("daemon mode", ...) does not exist
instead -- store mode %s - no data source / - with data source, looped over databaseModes
persistence API SetStore, SetCache also SetStoreMode(servicedef.DataStoreMode)

v2 hung these cases off the daemon mode subtree. On v3 the equivalent
configuration is "no data source": nothing but the store populates data. Rather
than reach into the databaseModes loop, the cases sit in their own top-level
t.Run("tombstones", ...) next to t.Run("read-write", ...), matching the
placement of the sibling cardinality port in #466.

Store mode governs the write path. With no data source there is nothing to
write, so read mode is the only mode these cases need. That is also what v2
got implicitly -- its daemonModePersistence set no store mode, and v3
defaults StoreMode to DataStoreModeRead.

All helpers the v2 file depended on exist unchanged on v3
(runWithEmptyStore, initialFlags, defaultPrefix, WriteMap,
EvalAllFlagsStateMap, makeFlagToCheckSegmentMatch,
pollUntilFlagValueUpdated). Only the import paths changed from v2 to v3.

Overlap with #466

v2 named its store configurer daemonModePersistence, which does not fit
v3's vocabulary. This branch renames it to uncachedReadModePersistence,
identical in name and body to the one #466 adds.

#466 has not merged yet, so both branches define it. Whichever merges second
must delete its copy -- the two helpers are byte-identical, so it is a delete,
not a reconciliation. Because they live in different files it will surface as a
duplicate-symbol build failure rather than a text conflict, so it is worth
watching for.

Red/green evidence

A/B against the Ruby SDK, which had a store wrapper that keyed its all-items
read off the key inside the record body. A keyless tombstone therefore lands
under an empty key and corrupts the collection.

Before (items_out[item[:key].to_sym]):

FAILED TESTS (2):
  * persistent data store/consul/tombstones/flags/body has no key
  * persistent data store/dynamodb/tombstones/flags/body has no key
Test Summary: 66 total, 35 skipped, 31 ran

Both failures report the same thing -- all-flags came back as a failed read that
served nothing, so the live flag was gone too:

result reason map key "flag-key" not found
full value was: {"state":{"$flagsState":{},"$valid":false}}

After (items_out[db_key[prefix.length..].to_sym]):

All tests passed
Test Summary: 66 total, 35 skipped, 31 ran

Redis passes on both sides. Full persistence suite on the fixed build, to
confirm the new subtree does not disturb the existing ones:
141 total, 14 skipped, 127 ran, all passed. The 14 skipped are the sibling
top-level suites excluded by the -run filter; nothing inside
persistent data store skipped.

Two cases cannot fail for the keying bug

Worth stating so nobody reads a green as a signal it is not:

  • The whole segments sub-tree. A flag matching a segment reads that one
    segment by key, so nothing in those cases triggers an all-segments read --
    which is the only thing this bug class affects. Confirmed above: the buggy
    build passes all three segment cases and fails only the flags one.
  • The $deleted full-object shape. For a deleted item, a body-keyed store
    files it under $deleted and a store-keyed one files it under the real key.
    Either way the deleted-filter drops it, so the result is identical. Verified
    empirically against live Consul.

They are included anyway, because they are cheap guards against parse failures
and resurrection bugs, which are real and distinct defect classes. No assertion
was added to try to make them detect the keying bug.

gofmt and go vet clean.


Note

Overview
Adds a tombstones subtree to the v3 server-side persistent store harness (alongside collection cardinality), ported from v2. The suite seeds Redis, Consul, and DynamoDB with each of the three cross-SDK tombstone JSON shapes—keyless {"version", "deleted"}, body key repeating the store key, and full objects whose inner key is "$deleted"—then runs with no data source and uncached read mode so reads come straight from the store.

Flag cases assert a tombstone next to live flags does not break the collection, the deleted key is missing from all-flags state and metadata, and single-flag evaluation returns the default with FLAG_NOT_FOUND. Segment cases use a flag that would match if the tombstone were treated as live; evaluation must stay not-matched, including when the full-object shape embeds the context in included.

Also adds requireFlagAbsentFromAllFlags to guard both flag values and $flagsState entries for deleted keys.

Reviewed by Cursor Bugbot for commit 832cdad. Bugbot is set up for automated code reviews on this repo. Configure here.

@jsonbailey
jsonbailey force-pushed the jb/sdk-3174/tombstones-v3 branch from 0d2eebd to fa66cac Compare September 28, 2026 17:59
@jsonbailey
jsonbailey changed the base branch from v3 to jb/sdk-3174/collection-cardinality-v3 September 28, 2026 17:59
@jsonbailey
jsonbailey added this pull request to stack #485 September 28, 2026 18:11
@jsonbailey
jsonbailey force-pushed the jb/sdk-3174/tombstones-v3 branch from fa66cac to 757c6d2 Compare September 28, 2026 18:49
Base automatically changed from jb/sdk-3174/collection-cardinality-v3 to v3 September 28, 2026 18:55
Stacked on the cardinality port, whose no-data-source persistence helper this
reuses.
@jsonbailey
jsonbailey force-pushed the jb/sdk-3174/tombstones-v3 branch from 757c6d2 to 832cdad Compare September 28, 2026 18:55
@jsonbailey
jsonbailey marked this pull request as ready for review September 28, 2026 18:55
@jsonbailey
jsonbailey requested a review from a team as a code owner September 28, 2026 18:55
@jsonbailey
jsonbailey merged commit a9a0696 into v3 Sep 28, 2026
7 checks passed
@jsonbailey
jsonbailey deleted the jb/sdk-3174/tombstones-v3 branch September 28, 2026 19:39
joker23 pushed a commit that referenced this pull request Oct 8, 2026
🤖 I have created a release *beep* *boop*
---


##
[3.2.0-alpha.11](v3.2.0-alpha.10...v3.2.0-alpha.11)
(2026-10-08)


### Features

* adding client side bootstrap tests
([#462](#462))
([9c1810d](9c1810d))
* Port client-side prerequisite cycle detection tests to v3
([#473](#473))
([7e65a58](7e65a58))
* port client-side streaming retry contract tests to v3
([#475](#475))
([f968442](f968442))


### Bug Fixes

* Verify all-items reads for empty and single-item collections
([#466](#466))
([489a780](489a780))
* Verify SDKs read all three persistent-store tombstone shapes
([#484](#484))
([a9a0696](a9a0696))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Overview**
> **Release 3.2.0-alpha.11** — automated version bump only:
`.release-please-manifest.json`, `versionString` in `main.go`, and a new
`CHANGELOG.md` section.
> 
> The changelog documents what ships in this alpha: **new contract
coverage** for client-side bootstrap, prerequisite cycle detection
(ported to v3), and streaming retry behavior; plus **harness fixes** for
all-items reads on empty/single-item persistent-store collections and
for all three persistent-store tombstone shapes.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
1a2073d. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants