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

[BUG] InMemoryEmbeddingStore has thread safety issues. #350

Closed
lexluo09 opened this issue Dec 13, 2023 · 0 comments
Closed

[BUG] InMemoryEmbeddingStore has thread safety issues. #350

lexluo09 opened this issue Dec 13, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@lexluo09
Copy link
Contributor

lexluo09 commented Dec 13, 2023

Describe the bug
InMemoryEmbeddingStore may encounter errors such as ConcurrentModificationException: null in multi-threaded or multiple invocations scenarios

Log and Stack trace

java.util.ConcurrentModificationException: null
	at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:911)
	at java.util.ArrayList$Itr.next(ArrayList.java:861)
	at dev.langchain4j.store.embedding.inmemory.InMemoryEmbeddingStore.findRelevant(InMemoryEmbeddingStore.java:122)
	at dev.langchain4j.store.embedding.EmbeddingStore.findRelevant(EmbeddingStore.java:67)

To Reproduce
When calling the findRelevant interface, simultaneously call the add method.

Please complete the following information:

  • LangChain4j version: e.g. 0.24.0
  • Java version: e.g. 1.8
  • Spring Boot version (if applicable): e.g. 2.7.14
@lexluo09 lexluo09 added the bug Something isn't working label Dec 13, 2023
langchain4j pushed a commit that referenced this issue Dec 14, 2023
fix the thread safety issue in InMemoryEmbeddingStore.

Log and Stack trace:
```
java.util.ConcurrentModificationException: null
at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:911)
at java.util.ArrayList$Itr.next(ArrayList.java:861)
at dev.langchain4j.store.embedding.inmemory.InMemoryEmbeddingStore.findRelevant(InMemoryEmbeddingStore.java:122)
at dev.langchain4j.store.embedding.EmbeddingStore.findRelevant(EmbeddingStore.java:67)
```

#350
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants