开发者社区> 问答> 正文

当前事务日志的插入位置 和当前日志写入位置的区别?

pg_current_xlog_insert_location() text 获取当前事务日志的插入位置
pg_current_xlog_location() text 获取当前事务日志的写入位置

展开
收起
pis-j 2015-12-31 07:54:55 4266 0
1 条回答
写回答
取消 提交回答
  • 公益是一辈子的事, I am digoal, just do it. 阿里云数据库团队, 擅长PolarDB, PostgreSQL, DuckDB, ADB等, 长期致力于推动开源数据库技术、生态在中国的发展与开源产业人才培养. 曾荣获阿里巴巴麒麟布道师称号、2018届OSCAR开源尖峰人物.
    
    pg_current_xlog_insert_location() text 获取当前事务日志的插入位置 ,指还在wal buffer中的位置。
    pg_current_xlog_location() text 获取当前事务日志的写入位置,指已经调用了write后的位置(但是sync到磁盘之前),所以一定不在wal buffer了.
    
    
    
    
    /*
     * Report the current WAL write location (same format as pg_start_backup etc)
     *
     * This is useful for determining how much of WAL is visible to an external
     * archiving process.  Note that the data before this point is written out
     * to the kernel, but is not necessarily synced to disk.
     */
    Datum
    pg_current_xlog_location(PG_FUNCTION_ARGS)
    {
            XLogRecPtr      current_recptr;
    
            if (RecoveryInProgress())
                    ereport(ERROR,
                                    (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
                                     errmsg("recovery is in progress"),
                                     errhint("WAL control functions cannot be executed during recovery.")));
    
            current_recptr = GetXLogWriteRecPtr();
    
            PG_RETURN_LSN(current_recptr);
    }
    
    /*
     * Report the current WAL insert location (same format as pg_start_backup etc)
     *
     * This function is mostly for debugging purposes.
     */
    Datum
    pg_current_xlog_insert_location(PG_FUNCTION_ARGS)
    {
            XLogRecPtr      current_recptr;
    
            if (RecoveryInProgress())
                    ereport(ERROR,
                                    (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
                                     errmsg("recovery is in progress"),
                                     errhint("WAL control functions cannot be executed during recovery.")));
    
            current_recptr = GetXLogInsertRecPtr();
    
            PG_RETURN_LSN(current_recptr);
    }
    
    
    2019-07-17 18:23:27
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
PostgresChina2018_赖思超_PostgreSQL10_hash索引的WAL日志修改版final 立即下载
Kubernetes下日志实时采集、存储与计算实践 立即下载
日志数据采集与分析对接 立即下载