Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store __inverseRels__ not cleaned up with transform option { useBuffer: true } #988

Open
enspandi opened this issue Mar 17, 2023 · 1 comment

Comments

@enspandi
Copy link
Contributor

enspandi commented Mar 17, 2023

We are using

settings.defaultTransformOptions = { useBuffer: true };

as otherwise the performance of indexeddb bulk operations is very very slow.

Unfortunately, with the latest version, we see that the store for keeping track of rels is not touched at all when removing a record.


Example:

// source = indexeddbsource
source.push([
  source.transformBuilder.removeRecord({ id: '123', type: 'test' })
]);

// Result in indexeddb with `useBuffer: true`
// 1. Record '123' is removed from store `test`
// 2. All relationships in store `__inverseRels__` of record '123' are still there

// Result in indexeddb with `useBuffer: false`
// 1. Record '123' is removed from store `test`
// 2. All relationships in store `__inverseRels__` of record '123' are removed

After some digging, I think the AsyncCacheIntegrityProcessor processor creates the transforms that clean up the __inverseRels__ store with useBuffer: false.

With useBuffer: true, it seems to be the job of SyncCacheIntegrityProcessor, but somehow it fails to return the changeset to remove the inverse rels @

const changes = buffer.stopTrackingChanges();

Versions

"@orbit/indexeddb": "0.17.2",
"@orbit/indexeddb-bucket": "0.17.0",
"@orbit/jsonapi": "0.17.1",
"@orbit/records": "0.17.0",
"@orbit/serializers": "0.17.0",
@enspandi
Copy link
Contributor Author

enspandi commented Mar 20, 2023

@dgeb I think the line here is missing to add the object to the _delta state, similar to what the addInverseRelationshipsSync above does:

this._delta.inverseRelationships[ri] = rels;

I patched the SimpleRecordTransformBuffer for now and it seems to work.

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

No branches or pull requests

1 participant