提交 90030cc7 编写于 作者: A Ashwin Agrawal

Print backtrace on AO format version error and check for same sooner.

In some scenarios ERROR "append-only table version -1 is invalid" is
being hit. Code inspection doens't reveal any clues why it can
happen. So, for now we thought of adding more info to figure out the
cause. Backtrace would definitely be helpful when the error hits.

Also, check the format version as soon as entry is read from
catalog. Plus also would be greatly helpful if can have corefile when
the problem happens so under the controlled environment with guc
evelate ERROR to PANIC. GUC
`debug_appendonly_print_verify_write_block` usage for same is not
ideal but wish to avoid adding special guc just for this case, hence
piggyback on this existing uinteresting debug guc for now.
Co-authored-by: NDaniel Gustafsson <dgustafsson@pivotal.io>
上级 d41f8be1
......@@ -262,6 +262,7 @@ GetFileSegInfo(Relation parentrel, Snapshot appendOnlyMetaDataSnapshot, int segn
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("got invalid formatversion value: NULL")));
AORelationVersion_CheckValid(fsinfo->formatversion);
/* get the state */
fsinfo->state = DatumGetInt16(
......@@ -441,9 +442,13 @@ GetAllFileSegInfo_pg_aoseg_rel(char *relationName,
/* get the file format version number */
formatversion = fastgetattr(tuple, Anum_pg_aoseg_formatversion, pg_aoseg_dsc, &isNull);
Assert(!isNull || appendOnlyMetaDataSnapshot == SnapshotAny);
if (!isNull)
oneseginfo->formatversion = (int64) DatumGetInt16(formatversion);
if (isNull)
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("got invalid formatversion value: NULL")));
AORelationVersion_CheckValid(formatversion);
oneseginfo->formatversion = DatumGetInt16(formatversion);
/* get the state */
state = fastgetattr(tuple, Anum_pg_aoseg_state, pg_aoseg_dsc, &isNull);
......@@ -453,7 +458,7 @@ GetAllFileSegInfo_pg_aoseg_rel(char *relationName,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("got invalid state value: NULL")));
else
oneseginfo->state = (int64) DatumGetInt16(state);
oneseginfo->state = DatumGetInt16(state);
/* get the uncompressed eof */
eof_uncompressed = fastgetattr(tuple, Anum_pg_aoseg_eofuncompressed, pg_aoseg_dsc, &isNull);
......
......@@ -173,7 +173,7 @@ SetNextFileSegForRead(AppendOnlyScanDesc scan)
Relation reln = scan->aos_rd;
int segno = -1;
int64 eof = 0;
int formatversion = -1;
int formatversion = -2; /* some invalid value */
bool finished_all_files = true; /* assume */
int32 fileSegNo;
......
......@@ -93,13 +93,16 @@ typedef enum AORelationVersion
#define AORelationVersion_IsValid(version) \
(version > AORelationVersion_None && version < MaxAORelationVersion)
extern bool Debug_appendonly_print_verify_write_block;
static inline void AORelationVersion_CheckValid(int version)
{
if (!AORelationVersion_IsValid(version))
{
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("append-only table version %d is invalid", version)));
ereport(Debug_appendonly_print_verify_write_block?PANIC:ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("append-only table version %d is invalid", version),
errprintstack(true)));
}
}
......
......@@ -244,7 +244,6 @@ extern bool Debug_appendonly_print_scan;
extern bool Debug_appendonly_print_scan_tuple;
extern bool Debug_appendonly_print_delete;
extern bool Debug_appendonly_print_storage_headers;
extern bool Debug_appendonly_print_verify_write_block;
extern bool Debug_appendonly_use_no_toast;
extern bool Debug_appendonly_print_blockdirectory;
extern bool Debug_appendonly_print_read_block;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册