Skip to content

fix: Prevent a hang when a stored item's key differs from its map key - #531

Draft
keelerm84 wants to merge 1 commit into
mainfrom
mk/SDK-3813/sorter-key-mismatch-hang
Draft

keelerm84 wants to merge 1 commit into
mainfrom
mk/SDK-3813/sorter-key-mismatch-hang

Conversation

@keelerm84

Copy link
Copy Markdown
Member

Requirements

  • I have added test coverage for new or changed functionality
  • I have followed the repository's pull request submission guidelines
  • I have validated my changes against all supported platform versions

Related issues

SDK-3813. Found while reviewing the work for #504.

Describe the solution you've provided

FeatureStoreDataSetSorter.add_with_dependencies_first removed each item from remaining_items by item[:key].to_sym. When the hash key differed from the item's own :key, nothing was removed and until remaining_items.empty? never ended. One trigger is an FDv2 put-object whose envelope key differs from object.key, with a writable persistent store: the sort runs inside set_basis while holding the Store lock, so the data system spins at 100% CPU and every evaluation blocks. A string-keyed collection hung the same way.

The sorter now tracks and outputs items by their map key. This matches Go (internal/toposort) and Java (DataModelDependencies), which both key the sort by the collection key.

Describe alternatives you've considered

Rejecting or normalizing a mismatched key in protocolv2.rb. Go and Java store a put-object under its envelope key and do not compare it with object.key, so the parser is left as it is.

Additional context

python-server-sdk's sorter (ldclient/feature_store.py _add_with_dependencies_first) deletes by the item's own key too. There it raises KeyError instead of looping, so the store init fails. That is tracked separately and not fixed here.

FeatureStoreDataSetSorter removed each item from the remaining set by the
item's own :key. When that differed from the hash key (for example an FDv2
put-object whose envelope key differs from object.key), nothing was removed
and the sort looped forever while holding the store lock. Track items by
their map key, as the Go and Java SDKs do.

SDK-3813

This branch has not been deployed

No deployments
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.

1 participant