Skip to content

Commit 8a9bfa5

Browse files
authored
Merge pull request #3767 from ingef/fix/race-condition-cce-load-storage
Fix: Race condition on loadStorage
2 parents 7860514 + 672e5e0 commit 8a9bfa5

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

backend/src/main/java/com/bakdata/conquery/io/storage/Store.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ public interface Store<KEY, VALUE> extends ManagedStore {
1414

1515
VALUE get(KEY key);
1616

17+
/**
18+
* Iterate over all key-value pairs in the store.
19+
* @param consumer Key-value consumer.
20+
* @implSpec The consumer must be thread-safe
21+
*/
1722
IterationStatistic forEach(StoreEntryConsumer<KEY, VALUE> consumer);
1823

1924
// TODO: 08.01.2020 fk: Is this still necessary? The implementation in XodusStore uses different methods that in our context don't act differently.

backend/src/main/java/com/bakdata/conquery/io/storage/xodus/stores/CachedStore.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import java.util.Collections;
66
import java.util.HashSet;
77
import java.util.Set;
8+
import java.util.concurrent.ConcurrentHashMap;
89
import java.util.concurrent.atomic.LongAdder;
910
import java.util.stream.Stream;
1011

@@ -153,7 +154,7 @@ public void loadData() {
153154

154155
final Stopwatch timer = Stopwatch.createStarted();
155156

156-
final Set<KEY> dupes = new HashSet<>();
157+
final Set<KEY> dupes = Collections.newSetFromMap(new ConcurrentHashMap<>());
157158

158159
store.forEach((key, value, size) -> {
159160
try {

0 commit comments

Comments
 (0)