Transaction Types
All database access occurs within transactions, which are defined by the enumerated values described in the following sections.
The following eXtremeDB transaction types are defined by enum
MCO_TRANS_TYPEinmco.h:typedef enum MCO_TRANS_TYPE_E_ { MCO_READ_ONLY = 0, MCO_UPDATE = 1, MCO_READ_WRITE = 2, MCO_EXCLUSIVE = 3 } MCO_TRANS_TYPE;MCO_READ_ONLYTransaction forREAD_ONLYaccess to data.MCO_UPDATETransaction for "read with intent to update" instead ofREAD_ONLY. If the intent is to find a database object for modification (update or delete), theMCO_UPDATEtransaction type should be specified. To update a database object, a newREAD_WRITEtransaction must be started, or the current transaction must be upgraded by calling functionmco_trans_upgrade().MCO_READ_WRITETransaction forREAD_WRITEaccess to data.MCO_EXCLUSIVE(AKA "Global Lock") No other transaction can run in parallel even if the Transaction Manager would normally allow it:MVCCwill not allowREAD_ONLYorREAD_WRITEtransactions while anEXCLUSIVEtransaction is working;MURSIWwill postpone execution of otherREAD_ONLYtransactions while anEXCLUSIVEtransaction is working (theEXCLUSIVETransaction Manager ignores any type of transaction because it runs just one transaction at a time regardless of type).Transaction Priorities
Transaction scheduling is partially determined by the transaction priority. Enum
MCO_TRANS_PRIORITYis defined inmco.has follows:typedef enum MCO_TRANS_PRIORITY_E_ { MCO_TRANS_IDLE = -2, /* Least important transactions */ MCO_TRANS_BACKGROUND = -1, MCO_TRANS_FOREGROUND = 0, /* Normal priority transactions */ MCO_TRANS_HIGH = 1, MCO_TRANS_ISR = 2 /* Very Important Transactions */ } MCO_TRANS_PRIORITY;Transaction priority can be set to one of the following values:
MCO_TRANS_IDLELeast important transactions.MCO_TRANS_BACKGROUNDLess important than foreground but more important than idle.MCO_TRANS_FOREGROUNDNormal priority transactions.MCO_TRANS_HIGHMore important than foreground but less important than ISR.MCO_TRANS_ISRVery important transactions.Transaction Scheduling Policy
The transaction scheduling policy for transactions with the same priority can be set to one of the following values as defined by enum
MCO_TRANS_SCHED_POLICYinmco.h:typedef enum MCO_TRANS_SCHED_POLICY_E_ { MCO_SCHED_FIFO = 0, /* First In First Out */ MCO_SCHED_READER_FAVOR = 1, /* Run read-only transactions first */ MCO_SCHED_WRITER_FAVOR = 2 /* Run read-write transactions first */ } MCO_TRANS_SCHED_POLICY;MCO_SCHED_FIFORuns transactions in first-in, first-out order.MCO_SCHED_READER_FAVORRuns read-only transactions first.MCO_SCHED_WRITER_FAVORRuns read-write transactions first.Transaction Object States
Within a transaction, objects can have one of the following states as defined by enum
MCO_TRANS_OBJ_STATEinmco.h:typedef enum MCO_TRANS_OBJ_STATE_ { MCO_TRANS_OBJ_CREATED = 0x01, MCO_TRANS_OBJ_DELETED = 0x02, MCO_TRANS_OBJ_ALL_DELETED = 0x04 } MCO_TRANS_OBJ_STATE;MCO_TRANS_OBJ_CREATEDThis object is being created.MCO_TRANS_OBJ_DELETEDThis object is being deleted.MCO_TRANS_OBJ_ALL_DELETEDAll objects of this class are being deleted.Transaction Isolation Levels
The transaction isolation level can be one of the following types as defined by enum
MCO_TRANS_ISOLATION_LEVELinmco.h:typedef enum MCO_TRANS_ISOLATION_LEVEL_E_ { MCO_DEFAULT_ISOLATION_LEVEL = 0x0, /* MCO_REPEATABLE_READ for MVCC, MCO_SERIALIZABLE for GlobalLock / MURSIW */ MCO_READ_COMMITTED = 0x1, /* Guarantees that any data read was committed at the moment is read. It restricts the reader from seeing any uncommitted data. */ MCO_REPEATABLE_READ = 0x2, /* In addition to MCO_READ_COMMITTED guarantees that any data read cannot change, if the transaction reads the same data again, it will find the previously read data in place, unchanged, and available to read. */ MCO_SERIALIZABLE = 0x4 /* Emulates serial transaction execution */ } MCO_TRANS_ISOLATION_LEVEL;MCO_DEFAULT_ISOLATION_LEVELMCO_REPEATABLE_READfor MVCC,MCO_SERIALIZABLEfor GlobalLock / MURSIW.MCO_READ_COMMITTEDGuarantees that any data read was committed at the moment it was read. It restricts the reader from seeing any uncommitted data.MCO_REPEATABLE_READIn addition toMCO_READ_COMMITTED, guarantees that any data read cannot change; if the transaction reads the same data again, it will find the previously read data in place, unchanged, and available to read.MCO_SERIALIZABLEEmulates serial transaction execution.Transaction Commit Policy
The transaction commit policy can be one of the following:
typedef enum MCO_COMMIT_POLICY_E { MCO_COMMIT_SYNC_FLUSH, /* Flush to disk on each commit (default) */ MCO_COMMIT_BUFFERED, /* Runtime buffered transactions */ MCO_COMMIT_DELAYED, /* Runtime buffered transactions, with commit criteria */ MCO_COMMIT_NO_SYNC /* Changes are not synchronously written to the disk */ } MCO_COMMIT_POLICY;MCO_COMMIT_SYNC_FLUSHFlushes to disk on each commit (default).MCO_COMMIT_BUFFEREDBuffers transactions at runtime.MCO_COMMIT_DELAYEDBuffers transactions at runtime with commit criteria.MCO_COMMIT_NO_SYNCDoes not synchronously write changes to the disk.