HiveException: xx with newer attempt ID 1 is smaller than the file xx with with older attempt ID 0

版本:HDP3.1.4 Hive3.1.0

异常描述:

java.io.IOException: File hdfs://cluster/tmp/hive/.hive-staging_hive_2021-04-09_10-08-47_704_718343819133902574-25365/_tmp.-ext-10002.moved/000316_1 with newer attempt ID 1 is smaller than the file hdfs://cluster/tmp/hive/.hive-staging_hive_2021-04-09_10-08-47_704_718343819133902574-25365/_tmp.-ext-10002.moved/000316_0 with older attempt ID 0)'
13929: 2021-04-09 10:24:43.608 | com.bx.slave.entity.JobTask.runJob(436) | org.apache.hadoop.hive.ql.metadata.HiveException: java.io.IOException: File hdfs://cluster/tmp/hive/.hive-staging_hive_2021-04-09_10-08-47_704_718343819133902574-25365/_tmp.-ext-10002.moved/000316_1 with newer attempt ID 1 is smaller than the file hdfs://cluster/tmp/hive/.hive-staging_hive_2021-04-09_10-08-47_704_718343819133902574-25365/_tmp.-ext-10002.moved/000316_0 with older attempt ID 0
13930: 2021-04-09 10:24:43.608 | at org.apache.hadoop.hive.ql.exec.FileSinkOperator.jobCloseOp(FileSinkOperator.java:1402)
13931: 2021-04-09 10:24:43.608 | at org.apache.hadoop.hive.ql.exec.Operator.jobClose(Operator.java:798)
13932: 2021-04-09 10:24:43.608 | at org.apache.hadoop.hive.ql.exec.Operator.jobClose(Operator.java:803)
13933: 2021-04-09 10:24:43.608 | at org.apache.hadoop.hive.ql.exec.Operator.jobClose(Operator.java:803)
13934: 2021-04-09 10:24:43.608 | at org.apache.hadoop.hive.ql.exec.tez.TezTask.close(TezTask.java:584)
13935: 2021-04-09 10:24:43.608 | at org.apache.hadoop.hive.ql.exec.tez.TezTask.execute(TezTask.java:321)
13936: 2021-04-09 10:24:43.609 | at org.apache.hadoop.hive.ql.exec.Task.executeTask(Task.java:212)
13937: 2021-04-09 10:24:43.609 | at org.apache.hadoop.hive.ql.exec.TaskRunner.runSequential(TaskRunner.java:103)
13938: 2021-04-09 10:24:43.609 | at org.apache.hadoop.hive.ql.Driver.launchTask(Driver.java:2712)
13939: 2021-04-09 10:24:43.609 | at org.apache.hadoop.hive.ql.Driver.execute(Driver.java:2383)
13940: 2021-04-09 10:24:43.609 | at org.apache.hadoop.hive.ql.Driver.runInternal(Driver.java:2055)
13941: 2021-04-09 10:24:43.609 | at org.apache.hadoop.hive.ql.Driver.run(Driver.java:1753)
13942: 2021-04-09 10:24:43.609 | at org.apache.hadoop.hive.ql.Driver.run(Driver.java:1747)
13943: 2021-04-09 10:24:43.609 | at org.apache.hadoop.hive.ql.reexec.ReExecDriver.run(ReExecDriver.java:157)
13944: 2021-04-09 10:24:43.609 | at org.apache.hive.service.cli.operation.SQLOperation.runQuery(SQLOperation.java:226)
13945: 2021-04-09 10:24:43.609 | at org.apache.hive.service.cli.operation.SQLOperation.access$700(SQLOperation.java:87)
13946: 2021-04-09 10:24:43.609 | at org.apache.hive.service.cli.operation.SQLOperation$BackgroundWork$1.run(SQLOperation.java:324)
13947: 2021-04-09 10:24:43.609 | at java.security.AccessController.doPrivileged(Native Method)
13948: 2021-04-09 10:24:43.609 | at javax.security.auth.Subject.doAs(Subject.java:422)
13949: 2021-04-09 10:24:43.609 | at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1730)
13950: 2021-04-09 10:24:43.609 | at org.apache.hive.service.cli.operation.SQLOperation$BackgroundWork.run(SQLOperation.java:342)
13951: 2021-04-09 10:24:43.609 | at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
13952: 2021-04-09 10:24:43.609 | at java.util.concurrent.FutureTask.run(FutureTask.java:266)
13953: 2021-04-09 10:24:43.610 | at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
13954: 2021-04-09 10:24:43.610 | at java.util.concurrent.FutureTask.run(FutureTask.java:266)
13955: 2021-04-09 10:24:43.610 | at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
13956: 2021-04-09 10:24:43.610 | at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
13957: 2021-04-09 10:24:43.610 | at java.lang.Thread.run(Thread.java:748)
13958: 2021-04-09 10:24:43.610 | Caused by: java.io.IOException: File hdfs://cluster/tmp/hive/.hive-staging_hive_2021-04-09_10-08-47_704_718343819133902574-25365/_tmp.-ext-10002.moved/000316_1 with newer attempt ID 1 is smaller than the file hdfs://cluster/tmp/hive/.hive-staging_hive_2021-04-09_10-08-47_704_718343819133902574-25365/_tmp.-ext-10002.moved/000316_0 with older attempt ID 0

重试文件的大小可能和压缩格式和写入顺序有关系,所以在校验id和文件大小的方式不恰当,因此去掉文件大小校验

源码地址:Utilities.java   

compareTempOrDuplicateFiles

PATCH地址:
https://issues.apache.org/jira/browse/HIVE-23354

(可以关闭mr和hive的推测执行,应用patch1)

<think>我们正在处理用户关于警告"execfileisnewerthancorefile"的问题。这个警告通常出现在使用调试器(如gdb)时,表示可执行文件(exec)的修改时间比核心转储文件(corefile)更新。这意味着在生成core文件之后,程序又被重新编译过。由于重新编译后的代码可能与core文件中的信息不匹配,这可能导致调试时信息不准确。然而,用户还提到这个警告可能与自定义的除法操作符重载相关。在之前的对话中,我们讨论过自定义除法操作符的重载,并增加了异常处理以避免除以零的情况。我们需要分析可能的关联点:1.这个警告是否可能是由于程序崩溃(比如除零异常)产生了core文件,然后用户修改了代码(比如修改了除法操作符)并重新编译,最后尝试用新编译的程序去调试旧的core文件?2.或者,这个警告只是一个独立的编译/运行环境问题,与除法操作符无关?解决步骤:1.首先,解释警告的含义。2.然后,说明为什么会出现这个警告,特别是与除法操作符重载可能存在的联系(例如,程序因为除零异常崩溃生成core文件,之后修改了除法操作符并重新编译)。3.提供解决方案:建议重新运行程序以生成新的core文件(如果问题仍然存在),或者使用与core文件匹配的可执行文件。但注意:用户提到的是“编译或运行时警告”,而该警告通常是调试时出现的。所以我们需要区分:编译时?->这个警告不是编译时产生的,而是调试时。运行时?->程序运行崩溃时可能会生成core文件,但警告是在调试时出现的。因此,解决方案主要围绕调试过程。另外,关于用户引用的内容(ProjectileMovementComponent等),似乎与问题无关,可以忽略。具体回答结构:1.解释警告:execfileisnewerthancorefile的含义2.分析可能的原因(包括与自定义除法操作符的关联)3.提供解决方案4.如何避免注意:如果用户正在调试一个因除法操作符导致除零异常而生成的core文件,并且此时已经修改了除法操作符的代码(比如增加了异常处理)并重新编译,那么就会出现警告。因为新的可执行文件已经和旧的core文件不匹配。解决方案:方案1:重新生成core文件。即用新的可执行文件运行并触发崩溃(如果问题依然存在),然后调试新的core文件。方案2:如果问题已经解决(不再崩溃),那么就不需要调试旧的core文件,可以删除它。方案3:如果必须调试旧的core文件,那么需要找到与core文件匹配的旧版本可执行文件(如使用版本控制工具找回)。重点:在调试时,确保可执行文件和core文件是同一时间点的产物。因此,回答如下:</think> ### 编译警告"exec file is newer than core file"解决方案及原因分析 此警告表明可执行文件(*exec*)比核心转储文件(*core*)更新,通常在**调试除零异常引发的崩溃**时出现,与您实现的`operator/`相关。以下是完整解决方案: #### 1. 警告产生机制 当发生除零异常时: ```mermaid graph TD A[程序运行] --> B{执行除法运算} B -->|除数为零| C[触发invalid_argument异常] C --> D[生成core dump文件] D --> E[开发者修复代码] E --> F[重新编译生成新exec文件] F --> G[用gdb调试旧core文件] G --> H[报错“exec file newer than core”] ``` #### 2. 根本原因 1. **时序不匹配** - 调试时使用的可执行文件版本($V_{\text{new}}$) - 与生成核心转储的旧版本($V_{\text{old}}$)不匹配 - 核心文件偏移量信息失效 2. **异常处理不足** 原始除法操作符仅处理`d == 0`的情况: ```cpp if (d == 0) throw... // 未处理次正规数(denormal)和NaN ``` #### 3. 完整解决方案 ##### 3.1 更新异常检测逻辑 ```cpp #include <cfenv> #include <cmath> TbPoint2f &operator/=(float d) { // 检测所有非法除数状态 if(std::fetestexcept(FE_DIVBYZERO) || std::isnan(d) || std::isinf(d) || std::fpclassify(d) == FP_SUBNORMAL) { throw std::domain_error("Invalid divisor in TbPoint2f division"); } // 安全阈值检查 constexpr float eps = std::numeric_limits<float>::epsilon(); if(std::fabs(d) <= 10 * eps) { throw std::range_error("Divisor below safe threshold"); } m_x /= d; m_y /= d; return *this; } ``` ##### 3.2 调试流程修正 ```bash # 1. 复现崩溃(使用更新后的程序) ./your_program # 2. 生成新core文件后立即调试 gdb -c core ./your_program # 3. 检查异常栈 (gdb) bt full ``` ##### 3.3 生成调试符号(CMake) ```cmake set(CMAKE_BUILD_TYPE Debug) # 强制生成调试符号 set(CMAKE_CXX_FLAGS "-g -O0 -fno-inline") # 禁用优化和内联 ``` #### 4. 核心原理验证 检查调试信息匹配性: $$ \text{match} = \begin{cases} 1 & \text{if } \text{offset}_{\text{exec}} == \text{offset}_{\text{core}} \\ 0 & \text{otherwise} \end{cases} $$ | 文件类型 | 时间戳要求 | 验证命令 | |---------|------------|----------| | 可执行文件 | $t_{\text{compile}}$ | `stat -c %y your_program` | | Core文件 | $t_{\text{crash}}$ | `stat -c %y core` | | 调试符号 | $t_{\text{compile}}$ | `readelf -S your_program\|grep debug` | #### 5. 预防措施 1. **自动core文件命名** ```bash # ~/.bashrc export kernel.core_pattern=core.%e.%p.%t ``` 2. **版本绑定调试** ```bash git checkout <crash_commit> gdb -c core.$(date +%s) ./build/$(git rev-parse HEAD)/program ```
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值