Skip to content

Commit

Permalink
Try to wait for or stop any outstanding write transactions when termi…
Browse files Browse the repository at this point in the history
…nating a thread
  • Loading branch information
kriszyp committed Apr 16, 2024
1 parent 0c4da4b commit 70368e4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/env.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@ void EnvWrap::cleanupStrayTxns() {
fprintf(stderr, "Deleting running worker\n");
delete worker;
}*/
pthread_mutex_lock(writingLock);
if (this->writeWorker) {
// signal that it is cancelled
this->writeWorker->env = nullptr;
}
pthread_mutex_unlock(writingLock);
while (this->readTxns.size()) {
TxnWrap *tw = *this->readTxns.begin();
mdb_txn_abort(tw->txn);
Expand Down
1 change: 1 addition & 0 deletions src/writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,7 @@ void WriteWorker::Write() {
envForTxn->lastReaderCheck = now;
}
pthread_mutex_lock(envForTxn->writingLock);
if (!env) return;// already closed
#ifndef _WIN32
int retries = 0;
retry:
Expand Down

0 comments on commit 70368e4

Please sign in to comment.