简体   繁体   English

pg_restore - 忽略特定错误

[英]pg_restore - ignore specific error

I've been handed a project from a coworker with zero knowledge of Postgres. 我从一个对Postgres一无所知的同事那里获得了一个项目。 I'm trying to integrate a pg_restore into a Jenkins Pipeline job and it returns one error that I have been told is fine to overlook. 我正在尝试将pg_restore集成到Jenkins管道作业中,并返回一个我被告知可以忽略的错误。 However, this error obviously causes the Jenkins job to fail, which is unideal. 但是,此错误显然会导致Jenkins作业失败,这是不理想的。

Is there a way to mitigate or stifle the output of this one error, without stopping any other (more serious) errors from being recorded? 有没有办法减轻或扼杀这一个错误的输出,而不停止记录任何其他(更严重的)错误?

The command I am running (with all personal data stripped) is 我正在运行的命令(剥离了所有个人数据)是

PGPASSWORD="password" pg_restore -h path -U user -d database filename -F c -c

and it returns this error (but executes successfully) 并返回此错误(但成功执行)

pg_restore: [archiver (db)] Error while PROCESSING TOC:
pg_restore: [archiver (db)] Error from TOC entry 8290; 0 0 COMMENT EXTENSION plpgsql 
pg_restore: [archiver (db)] could not execute query: ERROR:  must be owner of extension plpgsql
    Command was: COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';

Again, I have less than zero Postgres experience. 再次,我的Postgres经验不足为零。 Is there an easy way to ignore this one error, or is this just something I need to live with? 是否有一种简单的方法可以忽略这一个错误,或者这只是我需要忍受的东西?

If you run pg_restore as the user who owns the extension in the source database, that would fix the problem for real. 如果您在源数据库中以拥有扩展名的用户身份运行pg_restore ,则可以解决问题。

For just suppressing the issue: with old-style script steps, adding #!/bin/sh -x as the first line would prevent it from aborting on a non-zero return code (Jenkins normally runs shells with the -e option as well). 为了解决这个问题:使用旧式脚本步骤,添加#!/bin/sh -x作为第一行将阻止它在非零返回代码上中止(Jenkins通常使用-e选项运行shell) )。 It's worth a shot with a pipeline build but I don't know for sure if it'll work the same way. 使用管道构建值得一试,但我不确定它是否会以相同的方式工作。 If it does, do be aware that the script will continue after other bad return codes as well. 如果是,请注意脚本将在其他错误返回代码之后继续。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM