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

Add a lock around the block manager start #506

Merged
merged 1 commit into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions python/pdo/common/block_store_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,20 @@

# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
import threading
__block_manager_lock__ = threading.Lock()
__local_block_manager__ = None

def local_block_manager() :
global __local_block_manager__

__block_manager_lock__.acquire()
if __local_block_manager__ is None :
block_store_file = pconfig.shared_configuration(['StorageService','BlockStore'], "./blockstore.mdb")

__local_block_manager__ = BlockStoreManager(block_store_file, True)
__block_manager_lock__.release()

return __local_block_manager__

# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Expand Down
9 changes: 9 additions & 0 deletions python/pdo/common/key_value.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,19 @@
import logging
logger = logging.getLogger(__name__)

# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
import threading
__block_store_lock__ = threading.Lock()
__block_store_initialized__ = False

# -----------------------------------------------------------------
# -----------------------------------------------------------------
def KeyValueInitialize(block_store_file = None) :
global __block_store_initialized__

__block_store_lock__.acquire()

if __block_store_initialized__ :
raise Exception("duplicate block store initialization")

Expand All @@ -41,6 +48,8 @@ def KeyValueInitialize(block_store_file = None) :
kvs.block_store_open(block_store_file)
__block_store_initialized__ = True

__block_store_lock__.release()

# -----------------------------------------------------------------
# -----------------------------------------------------------------
def KeyValueTerminate() :
Expand Down