Private strand flush not complete 说明

本文解析了Oracle数据库中出现的Private strand flush not complete错误信息的原因及解决方案,涉及redo日志缓冲区的并行机制和私有strand的概念。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

前几天一个朋友问了我一个问题。说她在alert log里面看到了如下信息:

Thread 1 cannot allocate new log,sequence 415

Private strand flush not complete

Current log# 4 seq# 414 mem# 0: /dev/rora_redotb04

Thread 1 advanced to log sequence 415

Current log# 5 seq# 415 mem# 0: /dev/rora_redotb05

Thu Nov 11 16:01:51 2010

我遇到的是:Checkpoint not complete。有关这方面的解释参考我的Blog:

Redo Log和Checkpoint not complete

http://blog.youkuaiyun.com/xujinyang/article/details/6832719

在oracle官网搜了一下:

Alert Log Messages: Private Strand Flush Not Complete [ID 372557.1]


Modified01-SEP-2010TypePROBLEMStatusMODERATED

In this Document
Symptoms
Cause
Solution
References


Platforms: 1-914CU;

This document is being delivered to you via Oracle Support's Rapid Visibility (RaV) process and therefore has not been subject to an independent technical review.

Applies to:

Oracle Server - Enterprise Edition - Version: 10.2.0.1 to 11.1.0.7 - Release: 10.2 to 11.1
Information in this document applies to any platform.
"Checked for relevance on 04-Dec-2007"


Private strand flush not complete

Symptoms

"Private strand flush not complete" messages are being populated to the alert log for unknown
reasons.

ALERT LOG EXAMPLE:
>>>
Fri May 19 12:47:29 2006
Thread 1 cannot allocate new log, sequence 18358
Private strand flush not complete
Current log# 7 seq# 18357 mem# 0: /u03/oradata/bitst/redo07.log
Thread 1 advanced to log sequence 18358
Current log# 8 seq# 18358 mem# 0: /u03/oradata/bitst/redo08.log
<<<


>>

Cause

The message means that we haven't completed writing all the redo information to the log when we are trying to switch.It is similar in nature to a "checkpoint not complete"except that is only involves the redo being written to the log.The log switch can not occur until all of the redo has been written.

A "strand" is new terminology for 10g and it deals with latches for redo .

Strands are a mechanism to allow multiple allocation latches for processes to write redo more efficiently in the redo buffer and is related to the log_parallelism parameter present in 9i.

The concept of a strand is to ensure that the redo generation rate for an instance is optimal and that when there is some kind of redo contention then the number of strands is dynamically adjusted to compensate.

The initial allocation for the number of strands depends on the number of CPU's and is started with 2strands with one strand for active redo generation.

For large scale enterprise systems the amount of redo generation is large and hence these strands are *made active* as and when the foregrounds encounter this redo contention (allocated latch related contention) when this concept of dynamic strands comes into play.

There is always shared strands and a number of private strands .

Oracle 10g has some major changes in the mechanisms for redo (and undo), which seem to be aimed at reducing contention.

Instead of redo being recorded in real time, it can be recorded 'privately' and pumped into the redo log buffer on commit.

Similary the undo can be generated as 'in memory undo' and applied in bulk.

This affect the memory used for redo management and the possibility to flush it in pieces.

The message you get is related to internal Cache Redo File management.

You can disregard these messages as normal messages.

When you switch logs all private strands have to be flushed to the current log before the switch is allowed to proceed.

Solution

These messages are not a cause for concern unless there is a significant gap in seq# between the "cannot allocate new log" message and the "advanced to log sequence" message.


This issue is infact not a bug and is expected behavior.

In some cases, this message can be resolved by increasing db_writer_process value.

这里面涉及到一些Redo的机制问题。具体参考Blog:

Oracle Redo并行机制

http://blog.youkuaiyun.com/xujinyang/article/details/6831357

一个redo条目包含了相应操作导致的数据库变化的所有信息,所有redo条目最终都要被写入redo文件中去。Redo log buffer是为了避免Redo文件IO导致性能瓶颈而在sga中分配出的一块内存。一个redo条目首先在用户内存(PGA)中产生,然后由oracle服务进程拷贝到log buffer中,当满足一定条件时,再由LGWR进程写入redo文件。

由于log buffer是一块“共享”内存,为了避免冲突,它是受到redo allocation latch保护的,每个服务进程需要先获取到该latch才能分配redo buffer。因此在高并发且数据修改频繁的oltp系统中,我们通常可以观察到redo allocation latch的等待。

为了减少redo allocation latch等待,在oracle 9.2中,引入了log buffer的并行机制。其基本原理就是,将log buffer划分为多个小的buffer,这些小的buffer被成为Shared Strand。每一个strand受到一个单独redo allocation latch的保护。多个shared strand的出现,使原来序列化的redo buffer分配变成了并行的过程,从而减少了redo allocation latch等待。

为了进一步降低redo buffer冲突,在10g中引入了新的strand机制——Private strand。Private strand不是从log buffer中划分的,而是在shared pool中分配的一块内存空间。

Private strand的引入为Oracle的Redo/Undo机制带来很大的变化。每一个Private strand受到一个单独的redo allocation latch保护,每个Private strand作为“私有的”strand只会服务于一个活动事务。获取到了Private strand的用户事务不是在PGA中而是在Private strand生成Redo,当flush private strand或者commit时,Private strand被批量写入log文件中。如果新事务申请不到Private strand的redo allocation latch,则会继续遵循旧的redo buffer机制,申请写入shared strand中。事务是否使用Private strand,可以由x$ktcxb的字段ktcxbflg的新增的第13位鉴定:

对于使用Private strand的事务,无需先申请Redo Copy Latch,也无需申请Shared Strand的redo allocation latch,而是flush或commit是批量写入磁盘,因此减少了Redo Copy Latch和redo allocation latch申请/释放次数、也减少了这些latch的等待,从而降低了CPU的负荷。

看了这些理论知识,我们在来看一下之前的错误:

Private strand flush not complete

当我们flush或者commit的时候,必须先将buffer中的内容写入到redo中,才能去接收新的记录。这个错误就是发生在这个过程中。Oracle对这个问题提了2个方法:

(1)忽略,在使用之前,必须要等待buffer的信息flush完成。这时候进程是会短暂的hang住。

(2)增加db_writer_process的数据。

------------------------------------------------------------------------------

<think>我们正在讨论的是在终端中输入UPDATE和FLUSH命令时出现的'commandnotfound'错误。用户可能是在尝试执行某些数据库操作(如MySQL)或系统缓存刷新命令,但在普通终端中直接输入这些命令会导致错误,因为这些命令不是标准的系统命令。原因分析:1.用户可能误以为UPDATE和FLUSH是系统命令,但实际上它们是特定程序(如MySQL)中的命令。2.用户可能没有进入相应的程序(如MySQL命令行)而直接在系统终端中输入这些命令。3.用户可能想要执行系统更新(如`aptupdate`)或刷新DNS缓存(如`sudosystemd-resolve--flush-caches`),但记错了命令。解决方案:1.如果用户是想在MySQL中执行UPDATE或FLUSH命令,那么需要先登录MySQL命令行,然后在MySQL提示符下执行这些命令。例如:```mysql-uusername-pEnterpassword:mysql>UPDATEtable_nameSETcolumn1=value1WHEREcondition;mysql>FLUSHPRIVILEGES;```2.如果用户是想更新系统包(在Ubuntu/Debian系统中),正确的命令是`sudoaptupdate`(更新软件包列表),而不是`UPDATE`。类似地,刷新DNS缓存可以使用`sudosystemd-resolve--flush-caches`(适用于使用systemd-resolved的系统)或`sudo/etc/init.d/nscdrestart`(如果使用nscd)等。3.如果用户是想刷新终端或shell环境,通常可以使用`source~/.bashrc`或`.~/.bashrc`(对于bash)来重新加载配置文件,但这不是FLUSH命令。因此,用户需要根据实际意图使用正确的命令。为了帮助用户避免类似错误,可以说明:-在终端中直接执行的命令通常是系统命令或安装在PATH中的程序。-特定程序的命令需要在相应的程序环境中执行(如mysql、psql、python等)。生成相关问题:1.如何登录MySQL命令行?2.在Ubuntu中更新软件包的正确命令是什么?3.如何刷新DNS缓存?4.如何重新加载bash配置文件?</think>### 为什么在终端输入 UPDATE 和 FLUSH 会报错 "command not found"? 这个错误通常有以下几个原因: 1. **非系统级命令** `UPDATE` 和 `FLUSH` 不是 Linux/macOS 的系统命令,而是**数据库操作指令**(如 MySQL、SQLite)。直接在终端输入会被系统视为无效命令[^1]。 2. **缺少执行环境** 这些命令需要在特定环境中执行: - MySQL:需先进入 `mysql>` 交互界面 - SQLite:需在 `sqlite3>` 环境中执行 - Redis:需在 `redis-cli>` 中执行 3. **拼写错误/大小写敏感** Linux 终端命令严格区分大小写。`UPDATE` 应全大写(SQL语法),但系统命令通常小写(如 `apt update`)。 --- ### 解决方案 根据你的实际需求选择: #### ✅ 场景1:操作数据库 ```bash # MySQL 示例 mysql -u 用户名 -p Enter password: ****** # 输入密码 mysql> UPDATE 表名 SET 列=值 WHERE 条件; # 成功执行 mysql> FLUSH PRIVILEGES; ``` #### ✅ 场景2:更新系统软件包 ```bash # Ubuntu/Debian 系统 sudo apt update # 更新软件列表 sudo apt upgrade # 升级软件 # RedHat/CentOS 系统 sudo yum update ``` #### ✅ 场景3:刷新系统缓存 ```bash # 刷新DNS缓存 (Linux) sudo systemd-resolve --flush-caches # 刷新ARP缓存 sudo ip -s -s neigh flush all ``` #### ✅ 场景4:环境变量刷新 ```bash # 重载终端配置 (Bash) source ~/.bashrc # Zsh 终端 source ~/.zshrc ``` --- ### 关键总结 | 命令类型 | 执行位置 | 正确示例 | |----------|------------------|------------------------------| | SQL命令 | 数据库交互界面 | `mysql> UPDATE users SET...` | | 系统更新 | 终端直接执行 | `sudo apt update` | | 缓存刷新 | 终端直接执行 | `sudo systemd-resolve --flush-caches` | 如果需要在脚本中使用 SQL 命令,需通过数据库客户端调用,例如: ```bash mysql -e "UPDATE table SET column=1 WHERE id=123;" ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值