why does txid_current() assign new transaction-id?
Hi,hackers!
I have a question about txid_current().
it is "Why does txid_current() assign new transaction-id?".
When we executes txid_current() outside of transaction block, it assigns new transaction-id.
I guess it doesn't need to assign a new txid because txid_current() is just a read-only function.
I found a replaceable function by walking through pg-code, that is GetStableLatestTransactionId(void).
I attached a patch which changing just 1-line.
Could you please check the code?
Regards,
Naoya
txid_current has had the behavior of assigning a new transaction XID
when one is not assigned since its introduction. I don't think that it
is wise to change it now the way you do as many applications surely
rely on this assumption. Perhaps we could make the documentation
clearer about those things though, changing the description of this
function to "get current transaction ID, and assign a new one if one
is not assigned yet":
http://www.postgresql.org/docs/devel/static/functions-info.html
Regards,
--
Michael
Thank you for comments.
I understand your points.
For only to read a current transaction-id, I know we just have to use
txid_current_snapshot and that is a best way, but I feel a little bit
hassle to explain columns of txid_current_snapshot for my supporting customers..
(Xmin is .... and Xmax is ....) ..
I think that a description of txid_current is too rough and it might
be confused some users.
txid_current is a different operation depending on session situations,
I feel if detail of txid_current is documented then it will be better.
For example...
Inside of the transaction-block(begin..end), returns a transaction-id used by this block.
Outside of the transaction-block, returns a next transaction-id(but it is consumed by this function).
Regards,
Naoya
Attached is a doc patch among those lines.
--
Michael
| Name | Return Type | Description |
|---|---|---|
| txid_current() | bigint | get current transaction ID, assigning a new one if the current transaction does not have one |
| txid_current_snapshot() | txid_snapshot | get current snapshot |
Snapshot Components
| Name | Description |
|---|---|
| xmin | Earliest transaction ID (txid) that is still active. All earlier transactions will either be committed and visible, or rolled back and dead. |
| xmax | First as-yet-unassigned txid. All txids greater than or equal to this are not yet started as of the time of the snapshot, and thus invisible. |
| xip_list | Active txids at the time of the snapshot. The list includes only those active txids between xmin and xmax; there might be active txids higher thanxmax. A txid that is xmin <= txid < xmax and not in this list was already completed at the time of the snapshot, and thus either visible or dead according to its commit status. The list does not include txids of subtransactions. |
txid_snapshot's textual representation is xmin:xmax:xip_list. For example 10:20:10,14,15 means xmin=10, xmax=20, xip_list=10, 14, 15.
参考:
http://postgresql.nabble.com/why-does-txid-current-assign-new-transaction-id-td5851159.html
http://www.postgresql.org/docs/devel/static/functions-info.html
why does txid_current() assign new transaction-id?的更多相关文章
- Postgresql 锁查看
之前版本 PostgreSQL 的 pg_stat_activity 视图的 waiting 字段判断会话是否等待锁资源(通俗地讲, waiting 值为true表示申请不到锁资源处于等待状态),但是 ...
- FAQ – Automatic Undo Management (AUM) / System Managed Undo (SMU) (Doc ID 461480.1)
FAQ – Automatic Undo Management (AUM) / System Managed Undo (SMU) (Doc ID 461480.1) APPLIES TO: Orac ...
- Transaction recovery: lock conflict caught and ignored
Transaction recovery: lock conflict caught and ignored环境:RAC 4节点.oracle 11.2.0.4.redhat 5.9 64bit 问题 ...
- iOS内存管理retain,assign,copy,strong,weak
转自:http://www.cnblogs.com/nonato/archive/2013/11/28/3447162.html iOS的对象都继承于NSObject, 该对象有一个方法:retain ...
- Ehcache(2.9.x) - API Developer Guide, Transaction Support
About Transaction Support Transactions are supported in versions of Ehcache 2.0 and higher. The 2.3. ...
- ios中strong, weak, assign, copy
copy 和 strong(retain) 区别 1. http://blog.csdn.net/itianyi/article/details/9018567 大部分的时候NSString的属性都是 ...
- 总账:日记账导入流程(文档 ID 1591640.1)
文档内容 概要 历史记录 详细信息 GL_INTERFACE_CONTROL GL_INTERFACE_HISTORY GL_IMPORT_REFERENCES 摘要 ...
- Xcode工程编译错误:“Cannot assign to 'self' outside of a method in the init family”
#import <Foundation/Foundation.h> @interface EOCRectangle : NSObject<NSCoding> @property ...
- 全局ID的重要性
全局ID的重要性 体现在sharding的时候 gtid MySQL:global transaction id uuid:universally unique identifier guid:glo ...
随机推荐
- (转) Tomcat部署Web应用方法总结
原文:http://blog.csdn.net/yangxueyong/article/details/6130065 Tomcat部署Web应用方法总结 分类: Java web2011-01-11 ...
- 搭建EJB3开发环境
开发工具:myeclipse8.5.antjdk:1.5容器:jboss4.2.31.安装jboss:解压.配置JBOSS_HOME环境变量2.测试安装是否成功:启动%JBOSS_HOME%\bin\ ...
- BZOJ 2054 疯狂的馒头
并查集把染过色的并在一起.倒着染色. #include<iostream> #include<cstdio> #include<cstring> #include& ...
- PHP_ArrayList
<?php //遍历数组的2种方式 $arr=array( "1"=>"hello", "2"=>"my&q ...
- 批处理启动QQ
1.该方法只能启动一个qq.如果设置qq自启动时添加多个qq,则无法实现自动登陆 reg del "D:\TencentME\All Users\QQ\Registry.db"re ...
- Response响应请求操作
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Te ...
- mysql的ERROR:1042
在虚拟机上测试数据库备份功能,需要连接外部机器上的mysql,pdo总是报超时错误! 起初认为是用的mysql账号的域不匹配!后来发现不是因为这个! 在终端中用mysql命令尝试连接,发现返回的错误是 ...
- 第二个Sprint冲刺第四天
讨论地点:宿舍 讨论成员:邵家文.李新.朱浩龙.陈俊金 今天的发展,探讨了统计功能的问题: 一.统计数据针对的是什么功能? 1.初衷是针对计时的填空题,至于其它功能统不统计,那要看开发的进度. 二.对 ...
- Autoresizing和AutoLayout
1 使用Autoresizing的方式进行界面布局 1.1 问题 Autoresizing是IOS旧版的自动布局技术,现在仍然被很多企业使用.本案例将学习如何使用Autoresizing完成界面的布局 ...
- R语言决策树分类模型
rm(list=ls()) gc() memory.limit(4000) library(corrplot) library(rpart) data_health<-read.csv(&quo ...