Chapter 4. Concurrency

Table of Contents

Which BDB XML Handles are Free-Threaded
Locks, Blocks, and Deadlocks
Locks
Blocks
Deadlocks
The Locking Subsystem
Configuring the Locking Subsystem
Configuring Deadlock Detection
Resolving Deadlocks
Setting Transaction Priorities
Isolation
Supported Degrees of Isolation
Reading Uncommitted Data
Committed Reads
Using Snapshot Isolation
Read/Modify/Write
No Wait on Blocks
Explicit Transactions on Reads

BDB XML offers a great deal of support for multi-threaded and multi-process applications even when transactions are not in use. Many of BDB XML's handles are thread-safe, or can be made thread-safe by providing the appropriate flag at handle creation time, and BDB XML provides a flexible locking subsystem for managing containers in a concurrent application. Further, BDB XML provides a robust mechanism for detecting and responding to deadlocks . All of these concepts are explored in this chapter.

Before continuing, it is useful to define a few terms that will appear throughout this chapter:

Which BDB XML Handles are Free-Threaded

The following describes to what extent and under what conditions individual handles are free-threaded.

  • Environment

    Free-threaded so long as EnvironmentConfig.setThreaded() is set to true.

  • XmlManager

    This class free-threaded.

  • XmlTransaction

    Access must be serialized by the application across threads of control.

  • XmlCompression

    This class is free-threaded if the application is multi-threaded.

  • XmlContainer

    This class is free-threaded.

  • XmlContainerConfig

    This class is not free-threaded, and it can be safely used only by one thread of control.

  • XmlDebugListener

    Implemented by the application, and so whether this class can be shared across multiple threads is up to your local implementation.

  • XmlDocument

    This class is not free-threaded, and it can be safely used only by one thread of control.

  • XmlExternalFunction

    If XmlResolver.resolveExternalFunction() returns a new object, then it is not free-threaded. However, if the application is multi-threaded and resolveExternalFunction() returns a shared instance, then it is free-threaded.

  • XmlIndexSpecification

    This class is not free-threaded, and it can be safely used only by one thread of control.

  • XmlMetaDataIterator

    This class is not free-threaded, and it can be safely used only by one thread of control.

  • XmlQueryContext

    This class is not free-threaded, and it can be safely used only by one thread of control at a time.

  • XmlQueryExpression

    This class is free-threaded, and it can be safely used across multiple threads of control.

  • XmlResolver

    If an application uses multiple threads, custom implementations of XmlResolver must be free threaded to allow multiple, simultaneous calls for resolution.

  • XmlResults

    This class is not free-threaded, and it can be safely used only by one thread of control at a time.

  • XmlStatistics

    This class is not free-threaded, and it can be safely used only by one thread of control at a time.

  • XmlTransaction

    This class is not free-threaded, and it can be safely used only by one thread of control at a time.

  • XmlValue

    This class is not free-threaded, and it can be safely used only by one thread of control at a time.