Undo System Functions
- gs_undo_meta(type, zoneId, location)
Description: Specifies metadata of each module in the undo system.
Parameter description:
- type (metadata type)
The value 0 indicates the metadata corresponding to Undo Zone(Record).
The value 1 indicates the metadata corresponding to Undo Zone(Transaction Slot).
The value 2 indicates the metadata corresponding to Undo Space(Record).
The value 3 indicates the metadata corresponding to Undo Space(Transaction Slot).
- zoneId (undo zone ID)
The value –1 indicates the metadata of all undo zones.
The value range 0–1024 x 1024 indicates the metadata of the corresponding zone ID.
- location (read location)
The value 0 indicates that data is read from the current memory.
The value 1 indicates that data is read from a physical file.
Return type: record
Table 1 Output example of gs_undo_meta(0,-1,0) Category
Parameter
Type
Description
Output parameter
zoneId
oid
ID of the undo zone
Output parameter
persistType
oid
Persistence level
Output parameter
insert
text
Position of the next undo record to be inserted
Output parameter
discard
text
Position of the undo record that is recycled in common mode
Output parameter
end
text
Position of the undo record that is forcibly recycled. Values smaller than the value of this parameter indicate that the record has been recycled.
Output parameter
used
text
Used undo space
Output parameter
lsn
text
LSN to modify the zone
Output parameter
pid
oid
ID of the process bound to the zone
- type (metadata type)
- gs_undo_translot(location, zoneId)
Description: Specifies transaction slot information of the undo system.
Parameter description:
- location (read location)
The value 0 indicates that data is read from the current memory.
The value 1 indicates that data is read from a physical file.
- zoneId (undo zone ID)
The value –1 indicates the metadata of all undo zones.
The value range 0–1024 x 1024 indicates the metadata of the corresponding zone ID.
Return type: record
Table 2 Output example of gs_undo_translot(0,-1) Category
Parameter
Type
Description
Output parameter
groupId
oid
ID of the used undo zone
Output parameter
xactId
text
Transaction ID
Output parameter
startUndoPtr
text
Position where the undo record is inserted at the start of the transaction corresponding to a slot
Output parameter
endUndoPtr
text
Position where the undo record is inserted at the end of the transaction corresponding to a slot
Output parameter
lsn
text
Pointer to the corresponding slot
Output parameter
slot_states
oid
Transaction state. The options are as follows: 0: committed; 1: being executed; 2: being rolled back; 3: rolled back
- location (read location)
- gs_stat_undo()
Return type: record
Table 3 gs_stat_undo parameters Category
Parameter
Type
Description
Output parameter
curr_used_zone_count
uint32
Number of used undo zones.
Output parameter
top_used_zones
text
Information about the first three undo zones with the maximum usage. The output format is as follows:
(zoneId1:Used size; zoneId2:Used size; zoneId3:Used size).
Output parameter
curr_used_undo_size
uint32
Total size of the undo tablespace that is being used. The unit is MB.
Output parameter
undo_threshold
uint32
Calculation result of the value of the GUC parameter undo_space_limit_size x 80%. The unit is MB.
Output parameter
oldest_xid_in_undo
uint64
XID of the transaction recycled to the undo space. The undo records generated by the transaction whose XID is smaller than the value of XID are recycled.
Output parameter
oldest_xmin
uint64
Oldest active transaction.
Output parameter
total_undo_chain_len
int64
Total length of all accessed undo chains.
Output parameter
max_undo_chain_len
int64
Maximum length of the accessed undo chain.
Output parameter
create_undo_file_count
uint32
Number of created undo files.
Output parameter
discard_undo_file_count
uint32
Number of deleted undo files.
- gs_undo_record(undoptr)
Description: Undo record resolution.
Parameter description:
- undoptr (undo record pointer)
Return type: record
- gs_undo_dump_parsepage_mv(relpath text, blkno bigint, reltype text, rmem boolean)
Description: Parses the page header information of the disk page in the Ustore table, header information of each tuple, flag bit information, and all historical undo version information that can be queried.
Return type: text
Note: Only the system administrator or O&M administrator can execute this function.
Currently, this interface supports only Ustore tables.
Table 4 gs_undo_dump_parsepage_mv parameters Category
Parameter
Type
Description
Input parameter
relpath
text
Relative path of the Ustore table data file, in the format of Tablespace name/Database OID/relfilenode. For example, base/16603/16384. You can run the pg_relation_filepath('tablename') command to query the relative path.
Input parameter
blkno
bigint
- –1: All block pages are parsed.
- 0–MaxBlocNumber: A specified block page is parsed.
Input parameter
reltype
text
Table type. Currently, only the Ustore table is supported. The value is uheap.
Input parameter
rmem
boolean
Output parameter
output
text
Absolute path of the parsing result file.
- gs_undo_meta_dump_zone(zone_id int, read_memory boolean)
Description: Parses zone metadata in the undo module.
Return type: record
Table 5 gs_undo_meta_dump_zone parameters Category
Parameter
Type
Description
Input parameter
zone_id
int
Undo zone ID- –1: All undo zones are queried.
- 0–1048575: The undo zone metadata is queried based on the zone ID.
Input parameter
read_memory
boolean
- true: Data is read from the current memory.
- false: Data is read from the physical file.
Output parameter
zone_id
int
Undo zone ID
Output parameter
persist_type
int
Persistence level
- 0: ordinary table
- 1: unlogged table
- 2: temporary table
Output parameter
insert
text
Position of the next undo record to be inserted
Output parameter
discard
text
Position of the undo record that is recycled in common mode
Output parameter
forcediscard
text
Position of the undo record that is forcibly recycled. Values smaller than the value of this parameter indicate that the record has been recycled.
Output parameter
lsn
text
LSN to modify the zone
- gs_undo_meta_dump_spaces(zone_id int, read_memory boolean)
Description: Parses the metadata of the undo record space and undo slot space in the undo module.
Return type: record
Table 6 gs_undo_meta_dump_spaces parameters Category
Parameter
Type
Description
Input parameter
zone_id
int
Undo zone ID- –1: All undo zones are queried.
- 0–1048575: The undo zone metadata is queried based on the zone ID.
Input parameter
read_memory
boolean
- true: Data is read from the current memory.
- false: Data is read from the physical file.
Output parameter
zone_id
int
Undo zone ID
Output parameter
undorecord_space_tail
text
End position of the undo record space
Output parameter
undorecord_space_head
text
Start position of the undo record space
Output parameter
undorecord_space_lsn
text
LSN of the modified undo record space
Output parameter
undoslot_space_tail
text
End position of the undo slot space
Output parameter
undoslot_space_head
text
Start position of the undo slot space
Output parameter
undoreslot_space_lsn
text
LSN of the modified undo slot space
- gs_undo_meta_dump_slot(zone_id int, read_memory boolean)
Description: Parses slot metadata in the undo module.
Return type: record
Table 7 gs_undo_meta_dump_slot parameters Category
Parameter
Type
Description
Input parameter
zone_id
int
Undo zone ID- –1: All undo zones are queried.
- 0–1048575: The undo zone metadata is queried based on the zone ID.
Input parameter
read_memory
boolean
- true: Data is read from the current memory.
- false: Data is read from the physical file.
Output parameter
zone_id
int
Undo zone ID
Output parameter
allocate
text
Allocation position of the undo transaction slot
Output parameter
recycle
text
Recycling position of the undo transaction slot
Output parameter
frozen_xid
text
Frozen XID, which is used to determine the visibility
Output parameter
global_frozen_xid
text
Minimum frozen XID in the system. Transactions whose XID is smaller than the value of this parameter are visible.
Output parameter
recycle_xid
text
Recycled XID. Transactions whose XID is smaller than the value of this parameter are recycled.
Output parameter
global_recycle_xid
text
Minimum recycled XID in the system. Transactions whose XID is smaller than the value of this parameter are recycled.
- gs_undo_translot_dump_slot(zone_id int, read_memory boolean)
Description: Parses slots in a zone.
Return type: record
Table 8 gs_undo_translot_dump_slot parameters Category
Parameter
Type
Description
Input parameter
zone_id
oid
Undo zone ID- –1: All undo zones are queried.
- 0–1048575: The undo zone metadata is queried based on the zone ID.
Input parameter
read_memory
boolean
- true: Data is read from the current memory.
- false: Data is read from the physical file.
Output parameter
zone_id
text
Undo zone ID
Output parameter
slot_xid
text
Transaction ID
Output parameter
start_undoptr
text
Position where the undo record is inserted at the start of the transaction corresponding to a slot
Output parameter
end_undoptr
text
Position where the undo record is inserted at the end of the transaction corresponding to a slot
Output parameter
lsn
text
LSN of the modified slot
Output parameter
slot_states
oid
Transaction state- 0: committed
- 1: being executed
- 2: being rolled back
- 3: rolled back
- gs_undo_translot_dump_xid(slot_xid xid, read_memory boolean)
Description: Parses the slot in a zone based on the XID.
Return type: record
Table 9 gs_undo_translot_dump_xid parameters Category
Parameter
Type
Description
Input parameter
slot_xid
xid
XID to be queried
Input parameter
read_memory
boolean
- true: Data is read from the current memory.
- false: Data is read from the physical file.
Output parameter
zone_id
text
Undo zone ID
Output parameter
slot_xid
text
Transaction ID
Output parameter
start_undoptr
text
Position where the undo record is inserted at the start of the transaction corresponding to a slot
Output parameter
end_undoptr
text
Position where the undo record is inserted at the end of the transaction corresponding to a slot
Output parameter
lsn
text
LSN of the modified slot
Output parameter
slot_states
oid
Transaction state- 0: committed
- 1: being executed
- 2: being rolled back
- 3: rolled back
- gs_undo_dump_record(undoptr bigint)
Description: Parses undo records.
Return type: record
Table 10 gs_undo_dump_record parameters Category
Parameter
Type
Description
Input parameter
undoptr
bigint
Start position of the undo record to be parsed
Output parameter
undoptr
bigint
Start position of the undo record to be parsed
Output parameter
xactid
text
Transaction ID
Output parameter
cid
text
command id
Output parameter
reloid
text
relation oid
Output parameter
relfilenode
text
Relfinode of the file
Output parameter
utype
text
Undo record type
Output parameter
blkprev
text
Position of the previous undo record in the same block
Output parameter
blockno
text
Block number
Output parameter
uoffset
text
Undo record offset
Output parameter
prevurp
text
Position of the previous undo record
Output parameter
payloadlen
text
Length of the undo record data
Output parameter
oldxactid
text
Previous XID
Output parameter
partitionoid
text
Partition OID
Output parameter
tablespace
text
Tablespace
Output parameter
alreadyread_bytes
text
Length of the read undo record
Output parameter
prev_undorec_len
text
Length of the previous undo record
Output parameter
td_id
text
ID of the transaction directory
Output parameter
reserved
text
Whether to reserve the record
Output parameter
flag
text
Flag 1
Output parameter
flag2
text
Flag 2
Output parameter
t_hoff
text
Length of the undo record data header
- gs_undo_dump_xid(undo_xid xid)
Description: Parses undo records based on the XID.
Return type: record
Table 11 gs_undo_dump_xid parameters Category
Parameter
Type
Description
Input parameter
undo_xid
xid
XID
Output parameter
undoptr
xid
Start position of the undo record to be parsed
Output parameter
xactid
text
XID
Output parameter
cid
text
command id
Output parameter
reloid
text
relation oid
Output parameter
relfilenode
text
Relfinode of the file
Output parameter
utype
text
Undo record type
Output parameter
blkprev
text
Position of the previous undo record in the same block
Output parameter
blockno
text
Block number
Output parameter
uoffset
text
Undo record offset
Output parameter
prevurp
text
Position of the previous undo record
Output parameter
payloadlen
text
Length of the undo record data
Output parameter
oldxactid
text
Previous XID
Output parameter
partitionoid
text
Partition OID
Output parameter
tablespace
text
Tablespace
Output parameter
alreadyread_bytes
text
Length of the read undo record
Output parameter
prev_undorec_len
text
Length of the previous undo record
Output parameter
td_id
text
ID of the transaction directory
Output parameter
reserved
text
Whether to reserve the record
Output parameter
flag
text
Flag 1
Output parameter
flag2
text
Flag 2
Output parameter
t_hoff
text
Length of the undo record data header
- gs_verify_undo_record(type, startIdx, endIdx, location)
Description: Verifies the Undo record.
Return type: record
This interface is reserved for expansion and cannot be used.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot