Calling Chroma.from_documents() returns sqlite3.OperationalError: attempt to write a readonly database, but only sometimes
Labels: name: area: vector store, name: auto:bug, name: integration: chroma

### System Info

Platform: Ubuntu 22.04
Python: 3.11.6
Langchain: 0.0.351

### Who can help?

_No response_

### Information

- [ ] The official example notebooks/scripts
- [X] My own modified scripts

### Related Components

- [X] LLMs/Chat Models
- [ ] Embedding Models
- [ ] Prompts / Prompt Templates / Prompt Selectors
- [ ] Output Parsers
- [ ] Document Loaders
- [X] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction

When the program is first initialized with `__setup_client()` and `__should_reingest()` returns `True`, `__get_new_client()` works as intended. However, if `reingest()` is called afterward, `__get_new_client()` returns the error below.

Relevant code:
```python
def __setup_client(self) -> None:
    if self.__should_reingest():
        self.db = self.__get_new_client()
    else:
        self.db = self.__get_existing_client()

def reingest(self) -> None:
     self.db = self.__get_new_client()

 def __get_new_client(self):
    if os.path.exists(self.persist_directory):
        shutil.rmtree(self.persist_directory)

    docs = self.__get_docs()
    client = Chroma.from_documents(
        docs, self.embedding_function, persist_directory=self.persist_directory)

    with open(f'{self.persist_directory}/date.txt', 'w') as f:
        f.write(f'{datetime.date.today()}')
    return client
```

Error:
```
Traceback (most recent call last):
  ...
  File line 26, in reingest
    self.cauldron.reingest()
  File line 19, in reingest
    self.db = self.__get_new_client()
              ^^^^^^^^^^^^^^^^^^^^^^^
  File line 51, in __get_new_client
    client = Chroma.from_documents(
             ^^^^^^^^^^^^^^^^^^^^^^
  File ".../.pyenv/versions/3.11.6/lib/python3.11/site-packages/langchain_community/vectorstores/chroma.py", line 771, in from_documents
    return cls.from_texts(
           ^^^^^^^^^^^^^^^
  File ".../.pyenv/versions/3.11.6/lib/python3.11/site-packages/langchain_community/vectorstores/chroma.py", line 729, in from_texts
    chroma_collection.add_texts(
  File ".../.pyenv/versions/3.11.6/lib/python3.11/site-packages/langchain_community/vectorstores/chroma.py", line 297, in add_texts
    self._collection.upsert(
  File ".../.pyenv/versions/3.11.6/lib/python3.11/site-packages/chromadb/api/models/Collection.py", line 459, in upsert
    self._client._upsert(
  File ".../.pyenv/versions/3.11.6/lib/python3.11/site-packages/chromadb/telemetry/opentelemetry/__init__.py", line 127, in wrapper
    return f(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^
  File ".../.pyenv/versions/3.11.6/lib/python3.11/site-packages/chromadb/api/segment.py", line 446, in _upsert
    self._producer.submit_embeddings(coll["topic"], records_to_submit)
  File ".../.pyenv/versions/3.11.6/lib/python3.11/site-packages/chromadb/telemetry/opentelemetry/__init__.py", line 127, in wrapper
    return f(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^
  File ".../.pyenv/versions/3.11.6/lib/python3.11/site-packages/chromadb/db/mixins/embeddings_queue.py", line 172, in submit_embeddings
    results = cur.execute(sql, params).fetchall()
              ^^^^^^^^^^^^^^^^^^^^^^^^
sqlite3.OperationalError: attempt to write a readonly database
```

### Expected behavior

No error returned