Product Documentation

Knowledgebase

Previous Topic

Next Topic

6-Byte Transaction Numbers

FairCom DB associates a unique transaction number with every transaction. The transaction numbers assigned by the server start with transaction number 1 and are ever-increasing during the server’s operation.

When a FairCom DB client begins a transaction, the return value is the transaction number assigned to that transaction (or 0 in the case of an error). The server writes transaction numbers to the following persistent locations:

  • Transaction logs (the start files S*.FCS, and the log files L*.FCS)
  • TRNLOG indexes (in leaf nodes and header)
  • Superfile hosts (including the server’s FAIRCOM.FCS)

In This Section

Transaction Number Limitations Prior to V8

c-tree Server V8 Transaction Number Enhancements

When to Use 6-Byte Transaction Number Files

Creating 6-Byte Transaction Number Files

Configurable Transaction Number Overflow Warning Limit

Previous Topic

Next Topic

Transaction Number Limitations Prior to V8

Versions 6 and 7 of the c-tree Server support a 4-byte transaction number, of which 30 bits form the transaction number. For this reason, the maximum transaction number these versions of the c-tree Server support is 1,073,741,808 (0x3ffffff0).

When the server detects that the current transaction number is approaching the transaction number limit, it logs messages to the server status log, CTSTATUS.FCS, to inform the server administrator of an impending transaction number overflow. When the server detects a transaction number overflow it shuts down.

In the event of an impending transaction number overflow, the server administrator can follow these steps to restart the transaction numbering:

  • Perform a clean shutdown of the c-tree Server as indicated by the “Perform system checkpoint” in the server status log.
  • Delete the transaction logs: files S0000000.FCS, S0000001.FCS, and L*.FCS.
  • Use the ctclntrn utility on all TRNLOG indexes and superfile hosts (this includes the c-tree Server files FAIRCOM.FCS and SYSLOGIX.FCS) to reset the transaction numbers in the leaf nodes and index header.
  • Restart the c-tree Server. The server creates new transaction logs and starts numbering transactions from 1 again.

Note: When the c-tree Server opens a TRNLOG index, the server compares the transaction number high water mark in the index header to the current transaction number. If the value in the index header is larger than the current transaction number and the open occurs outside a transaction, the server sets the current transaction number to the transaction number high water mark value from the index header. This behavior is significant because it means that opening an index containing a reference to a large transaction number can cause the transaction number to jump to a large value. This could happen if an index was omitted from the ctclntrn processing or an index was restored from a backup taken before the clean operation.

Previous Topic

Next Topic

c-tree Server V8 Transaction Number Enhancements

For systems that must sustain a high transaction rate, the transaction number limit of the version 6 and version 7 c-tree Server can have significant implications for the availability of the c-tree Server. As an example, a system with a sustained rate of 1000 transactions per second would exceed the 4-byte transaction number limit in about 12 days of continuous operation.

To overcome this limitation, FairCom added support for 6-byte transaction numbers (also known as extended transaction numbers) to version 8 of the c-tree Server. The use of 6-byte transaction numbers (46 bits of which are used for the transaction number) provides the server the ability to sustain a rate of 1000 transactions per second for over 2000 years (as compared to the 12 day limit when using 4-byte transaction numbers).

The V8 c-tree Server always stores transaction numbers in the transaction logs as 6-byte values and stores transaction numbers as either 4-byte or 6-byte numbers depending on the index creation options. All indexes that the server creates for its own internal use are created as 6-byte transaction number indexes, so the only possible source of 4-byte transaction numbers is an application that creates index files as 4-byte transaction number files. If the application creates all its indexes as 6-byte transaction number files, the server will not be subject to the 4-byte transaction number limit.

Previous Topic

Next Topic

When to Use 6-Byte Transaction Number Files

Use 6-byte transaction number files for high transaction rate systems to avoid the 4-byte transaction number limit, because the server must be shut down and indexes and superfile hosts cleaned when the transaction number limit is reached.

Previous Topic

Next Topic

Creating 6-Byte Transaction Number Files

To create 6-byte transaction number files (this applies to superfile hosts and indexes), create an array of XCREblk (extended create block) structures, one for each physical data and index file to be created. Include the ct6BTRAN attribute in the x8mode field of each extended create block structure corresponding to an index file or superfile host. Call an Xtd8 create function such as CreateIFileXtd8(), passing the extended create block array to the function.

In order to ensure that only 6-byte transaction number files are opened by the server, specify the following keyword in the server configuration file:

COMPATIBILITY EXTENDED_TRAN_ONLY

This keyword causes a R6BT_ERR (745, 6BTRAN file required) on an attempt to create or open a non-extended-transaction-number file. (Note that a read-only open is not a problem since the file cannot be updated.)

Previous Topic

Next Topic

Configurable Transaction Number Overflow Warning Limit

When FairCom DB supports 6‑byte transaction numbers it does not display transaction overflow warnings until the current transaction number approaches the 6‑byte transaction number limit. But if 4‑byte transaction number files are in use, a key insert or delete will fail if the current transaction number exceeds the 4‑byte transaction number limit (however, FairCom DB will continue operating).

To allow a server administrator to determine when the server’s transaction number is approaching the 4‑byte transaction number limit, the following configuration option was added:

TRAN_OVERFLOW_THRESHOLD <transaction_number>

This keyword causes the c-tree Server to log the following warning message to CTSTATUS.FCS and to standard output (or the message monitor window on Windows systems) when the current transaction number exceeds the specified transaction number:

WARNING: The current transaction number (####) exceeds the user-defined threshold.

The message is logged every 10000 transactions once this limit has been reached. The TRAN_OVERFLOW_THRESHOLD limit can be set to any value up to 0x3ffffffffffff, which is the highest 6‑byte transaction number that FairCom DB supports.

TOCIndex