Skip to content

Conversation

@at055612
Copy link
Collaborator

@at055612 at055612 commented Nov 4, 2021

Fixes #185

  • Change Cursor and Txn to hold the Env instance so it can be checked for its open/closed state.
  • Add calls to env.checkNotClosed() in methods that call out to the LMDB lib to prevent the JVM crashing if the env has been closed.
  • Add lots of tests involving env closure.

Happy to re-work this if you disagree with the approach or see problems with it.

Change Cursor and Txn to hold the Env instance so it can be checked
for its open/closed state.
Add calls to env.checkNotClosed() in methods that call out to the LMDB
lib to prevent the JVM crashing if the env has been closed.
Add lots of tests involving env closure.
@at055612
Copy link
Collaborator Author

at055612 commented Nov 4, 2021

@benalexau If I run the test classes in isolation they work fine but when run via mvn test I see

# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007f4ec41f6a15, pid=22462, tid=22468
#
# JRE version: OpenJDK Runtime Environment (15.0.2+7) (build 15.0.2+7-27)
# Java VM: OpenJDK 64-Bit Server VM (15.0.2+7-27, mixed mode, sharing, tiered, compressed oops, g1 gc, linux-amd64)
# Problematic frame:
# C  [libpthread.so.0+0x9a15]  __pthread_mutex_lock_full+0x335

My suspicion (with zero c knowledge) is that the various tests that are closing the env while txns/cursors/dbis are open are leaving things (i.e. mutex locks) in an untidy state that are then causing later tests to fail. Does this seem right and is there any way to get around this?

An alternative approach would be for the Env to keep a track of open txns/cursors and either prevent closure of the env if any are open or force closure of the open txns/cursors. Such an approach would add overhead though.

@benalexau
Copy link
Member

Thanks @at055612 for this PR and my apologies for the delay in reviewing it. I have merged your changes via commit 3db0def. I added a Maven Surefire configuration to avoid reusing the forked test processes and that overcame the error.

@benalexau benalexau closed this Feb 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SIGSEGV on cursorIterable.next() when the env is closed

2 participants