33 PSpaceMap

The PSpaceMap stores a map from name of the PSpace to OID. The entire PSpaceMap is stored in the serial element with OID = PSPACEMAP_SEID.

The (entire) PSpaceMap is loaded when the store is first opened.

The committed flag

Each entry in the PSpaceMap has a committed flag. When the PSpaceMap is written to disk only the committed PSpace entries are serialised.

Consider that a PSpace is created as part of a transaction. The transaction will have exclusive write access to the new PSpace. Therefore no other threads will be able to make changes to the PSpace until the transaction commits. The creation of the new PSpace is tied to the transaction. This is turn ties the creation to a group of dirty PSpaces that are all processed later in a single Lss transaction. The new PSpace is a member of the group. When the group is processed by the DosWriter the new PSpace is marked as committed in the PSpaceMap. This in turn marks the PSpaceMap as dirty and it is written to disk as part of the same Lss transaction.

Thread safety

The PSpaceMap is accessed as follows:-

  • The PSpaceMap is only deserialised when an existing store is first opened
  • The PSpaceMap is only serialised by the DosWriter
  • CommitPSpace() is only called by the DosWriter
  • OpenPSpace() may be called by any thread that has opened a transaction
  • ClosePSpace() may be called by any thread at any time as long as the PSpace is no longer involved in a transaction.

Clearly the PSpaceMap needs to be threadsafe. Furthermore serialisation needs to be protected.

PSpaceMap.h

Source: Ceda/cxPersistStore/src/PSpaceMap.h

PSpaceMap.cpp

Source: Ceda/cxPersistStore/src/PSpaceMap.cpp