commercetools / commercetools/commercetools-sync-java

When using ProductSync with multiple ProductDrafts that reference product types, the library may issue multiple duplicate requests to fetch all product types.

Offen
#1,228 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Java
Sterne
40
Forks
41
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

**Describe the bug**
ProductTypeServiceImpl.fetchCachedProductAttributeMetaDataMap(productTypeId) checks:

`if (productsAttributesMetaData.isEmpty()) {
return fetchAndCacheProductMetaData(productTypeId);
}
`
On the very first calls, the cache is still empty.
Each concurrent (or even sequential but fast) call triggers its own QueryUtils.queryAll(...).
Because the caching happens asynchronously, subsequent calls still see the cache as empty until the first queryAll finishes.
As a result, multiple identical full queries for product types are executed.

**To Reproduce**
Steps to reproduce the behavior:
Call sync with multiple ProductDrafts that reference product types

**Expected behavior**
The first call should trigger one asynchronous cache warm-up.
All subsequent calls (while the warm-up is in progress) should wait for the same future instead of starting new queries.

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.