GaussDB的gs_dump工具問題整理,疑似BUG

PiscesCanon發表於2024-03-14

GaussDB的gs_dump工具問題整理,疑似BUG

目前分散式GaussDB用起來問題感覺巨多啊。

版本資訊如下:

09:04:11 root@postgres > select version();
-[ RECORD 1 ]----------------------------------------------------------------------------------------------------------------------
version | gaussdb (GaussDB Kernel 503.1.0.SPC2000 build 15786b02) compiled at 2023-12-12 22:07:15 commit 5868 last mr 14483 release

Time: 1.951 ms
09:04:12 root@postgres > select * from v$version;
-[ RECORD 1 ]-+--------------------------------------------------------
banner        | gaussdb (GaussDB Kernel 503.1.0.SPC2000 build 15786b02)
banner_full   | gaussdb (GaussDB Kernel 503.1.0.SPC2000 build 15786b02)
banner_legacy | gaussdb (GaussDB Kernel 503.1.0.SPC2000 build 15786b02)
con_id        | 0

Time: 2.081 ms

gs_dump本身功能不多,問題還很多,而且分散式GaussDB到集中式GaussDB使用gs_dump本質上會有少部分語法不相容需要純文字格式匯出進行編輯。

此版本的分散式GaussDB目前也不支援間隔分割槽等等等等。。

這裡列三個遇到的問題。

問題1:匯出庫的時候,庫中存在包和包體會有warning。

若是純文字匯出測試看,包,包體是有成功匯出的,也能夠成功匯入。

目前不知道有無隱患。是否為BUG。

環境模擬指令碼如下:

create database zkmdb owner root encoding 'UTF8' tablespace szceb template = template0 dbcompatibility = 'A';
\c zkmdb
create user zkm identified by 'huawei@123Pwd';

set current_schema=zkm;

Create Table T_PsnSalary
(
Fpsncode varchar(4),
Fpsndesc varchar(20),
FpsnBirth varchar(20),
FpsnSalary number(8,2)
);

Insert into T_PsnSalary(Fpsncode,Fpsndesc,FpsnBirth,FpsnSalary) Values('C001','張三','1986.01.10',1100);
Insert into T_PsnSalary(Fpsncode,Fpsndesc,FpsnBirth,FpsnSalary) Values('C002','李四','1980.10.10',3000);
Insert into T_PsnSalary(Fpsncode,Fpsndesc,FpsnBirth,FpsnSalary) Values('C003','王五','1996.12.10',800);



create or replace package A_GetData is
  function Getage(birthst varchar,birthend varchar) return integer;
  function Getsalary(VFpsncode varchar) return number;
end A_Getdata;
/

create or replace package body A_GETDATA is
  function Getage(birthst varchar,birthend varchar) return integer
  is
    V_birth integer;
    ToDateEnd Date;
    Toyear number(4);
    Tomonth number(4);
    Fromyear number(4);
    Frommonth number(4);
  begin
    if (birthend='') or (birthend is null) then
    select sysdate into ToDateEnd;
    end if;
    Toyear := to_number(to_char(ToDateEnd,'YYYY'));
    Tomonth := to_number(to_char(ToDateEnd,'MM'));
    Fromyear := to_number(substr(birthst,1,4));
    Frommonth := to_number(substr(birthst,6,2));
    if Tomonth-Frommonth>0 then V_birth:=Toyear-fromyear;
    else V_birth:=Toyear-fromyear-1;
    end if;
    return(V_birth);
  end;

  function getSalary(VFpsncode varchar) return number
  is
    V_psnSalary number(8,2);
  begin
    Select FpsnSalary into V_psnSalary from T_PsnSalary  where Fpsncode=VFpsncode;
    return(V_psnSalary);
  end;

end A_GETDATA;
/


select a.*,zkm.A_getdata.Getage(Fpsnbirth,'') age from zkm.T_psnsalary a;
select zkm.A_getdata.Getsalary('C001');

使用gs_dump匯出資訊:

[omm@gaussdb backup]$ gs_dump -p 30100 -U root -W jiamiPwd -f /backup/zkmdb.dmp -F c -E 'UTF8' -C zkmdb
gs_dump[user='root'][localhost][port='30100'][zkmdb][sorter][2024-03-12 17:33:21]: WARNING: could not resolve dependency loop among these items:
gs_dump[user='root'][localhost][port='30100'][zkmdb][sorter][2024-03-12 17:33:21]:   FUNCTION getage  (ID 1893 OID 23562)
gs_dump[user='root'][localhost][port='30100'][zkmdb][sorter][2024-03-12 17:33:21]:   object type 20  (ID 6624 OID 23561)
gs_dump[user='root'][localhost][port='30100'][zkmdb][sorter][2024-03-12 17:33:21]:   PRE-DATA BOUNDARY  (ID 6626)
gs_dump[user='root'][localhost][port='30100'][zkmdb][sorter][2024-03-12 17:33:21]: WARNING: could not resolve dependency loop among these items:
gs_dump[user='root'][localhost][port='30100'][zkmdb][sorter][2024-03-12 17:33:21]:   FUNCTION getsalary  (ID 1894 OID 23563)
gs_dump[user='root'][localhost][port='30100'][zkmdb][sorter][2024-03-12 17:33:21]:   object type 20  (ID 6624 OID 23561)
gs_dump[user='root'][localhost][port='30100'][zkmdb][sorter][2024-03-12 17:33:21]:   PRE-DATA BOUNDARY  (ID 6626)
gs_dump[user='root'][localhost][port='30100'][zkmdb][2024-03-12 17:33:21]: The total objects number is 451.
gs_dump[user='root'][localhost][port='30100'][zkmdb][2024-03-12 17:33:21]: [100.00%] 451 objects have been dumped.
gs_dump[user='root'][localhost][port='30100'][zkmdb][archiver][2024-03-12 17:33:21]: WARNING: archive items not in correct section order
gs_dump[user='root'][localhost][port='30100'][zkmdb][2024-03-12 17:33:21]: dump database zkmdb successfully
gs_dump[user='root'][localhost][port='30100'][zkmdb][2024-03-12 17:33:21]: total time: 3292  ms

問題2:

以純文字格式匯出庫 zkmdb 的某些schema的後設資料,匯出語句如下:

其中當出現 -n 指定schema匯出的時候,-C引數會失效。

gs_dump -p 8000 -U root -W jiamipwd -f /backup/metadata_zkmdb.sql -F p -s -C zkmdb -n user1 -n user2 -n user3 -n user4

一些含義:
gs_dump --help              
-f, --file=FILENAME
-F, --format=c|d|t|p                        output file format (custom, directory, tar,plain text (default))
-E, --encoding=ENCODING                     
-C, --create                                include commands to create database in dump
--exclude-function                          do not dump function and procedure
-s, --schema-only                           dump only the schema, no data


問題3:

nohup gs_dump 引數1 引數2 引數3 > /backup/exp_db.log &

使用日誌重定向儲存日誌時,指揮記錄部分匯出資訊的日誌到log檔案中,而大部分如報錯資訊指揮在當前螢幕中顯示而不記錄日誌。

略。

相關文章