Skip to content

Commit

Permalink
fix(#677): invalid store key used for persistence
Browse files Browse the repository at this point in the history
  • Loading branch information
novoj committed Nov 21, 2024
1 parent 4a68d37 commit 7aec178
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
11 changes: 3 additions & 8 deletions evita_engine/src/main/java/io/evitadb/core/Catalog.java
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ public final class Catalog implements CatalogContract, CatalogVersionBeyondTheHo
/**
* Contains reference to the archived catalog index that allows fast lookups for entities across all types.
*/
@Nullable
private CatalogIndex archiveCatalogIndex;
/**
* Isolated sequence service for this catalog.
Expand Down Expand Up @@ -409,6 +410,7 @@ public Catalog(
.orElseGet(() -> new CatalogIndex(Scope.LIVE));
this.catalogIndex.attachToCatalog(null, this);
this.archiveCatalogIndex = this.persistenceService.readCatalogIndex(this, Scope.ARCHIVED)
.filter(it -> !it.isEmpty())
.orElse(null);
if (this.archiveCatalogIndex != null) {
this.archiveCatalogIndex.attachToCatalog(null, this);
Expand Down Expand Up @@ -490,7 +492,7 @@ public Catalog(
long catalogVersion,
@Nonnull CatalogState catalogState,
@Nonnull CatalogIndex catalogIndex,
@Nonnull CatalogIndex archiveCatalogIndex,
@Nullable CatalogIndex archiveCatalogIndex,
@Nonnull Collection<EntityCollection> entityCollections,
@Nonnull Catalog previousCatalogVersion
) {
Expand Down Expand Up @@ -1380,13 +1382,6 @@ void flush() {
changeOccurred = changeOccurred || entityCollection.getVersion() != lastSeenVersion;
}

if (this.archiveCatalogIndex != null && this.archiveCatalogIndex.isEmpty()) {
this.dataStoreBuffer.removeIndex(
this.archiveCatalogIndex.getIndexKey(),
catalogIndexKey -> this.archiveCatalogIndex = null
);
}

if (changeOccurred) {
this.persistenceService.flushTrappedUpdates(
0L,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@ public static long getStoragePartPKForScope(@Nonnull Scope scope) {
@Nullable
@Override
public Long getStoragePartPK() {
return getStoragePartPKForScope(catalogIndexKey.scope());
return getStoragePartPKForScope(this.catalogIndexKey.scope());
}

@Override
public long computeUniquePartIdAndSet(@Nonnull KeyCompressor keyCompressor) {
return 1L;
return getStoragePartPKForScope(this.catalogIndexKey.scope());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ void shouldArchiveEntityAndMoveToArchivedIndexes() {
assertNotNull(getReferencedEntityIndex(productCollection3, Scope.LIVE, Entities.BRAND, 1));
assertNull(getReferencedEntityIndex(productCollection3, Scope.LIVE, Entities.BRAND, 2));

assertNull(catalog3.getCatalogIndexIfExits(Scope.ARCHIVED).orElse(null));
assertNull(catalog3.getCatalogIndexIfExits(Scope.ARCHIVED).filter(it -> !it.isEmpty()).orElse(null));
assertNull(getGlobalIndex(productCollection3, Scope.ARCHIVED));
assertNull(getReferencedEntityIndex(productCollection3, Scope.ARCHIVED, Entities.CATEGORY, 1));
assertNull(getReferencedEntityIndex(productCollection3, Scope.ARCHIVED, Entities.CATEGORY, 2));
Expand Down

0 comments on commit 7aec178

Please sign in to comment.