提交 744a5853 编写于 作者: J Joao Pereira 提交者: =

Convert Insist and insist_log into Assert and ereport on backend/utils

User elog instead of ereport to align with upstream.

Upstream uses elog instead of ereport for error that should only be
reachable if there is a bug in the code
上级 2a8973ea
......@@ -602,7 +602,8 @@ Cache_Insert(Cache *cache, CacheEntry *entry)
* This should never happen since the SyncHT has as many entries as the SharedCache,
* and we'll run out of SharedCache entries before we fill up the SyncHT
*/
insist_log(NULL != anchor, "Could not insert in the cache: SyncHT full");
if (anchor == NULL)
elog(ERROR, "Could not insert in the cache: SyncHT full");
/* Acquire anchor lock to touch the chain */
SpinLockAcquire(&anchor->spinlock);
......
......@@ -479,7 +479,7 @@ determine_datumstream_compression_overflow(
*/
desiredOverflowBytes =
(int) (desiredCompSizeFunc) (maxAoBlockSize) - maxAoBlockSize;
Insist(desiredOverflowBytes >= 0);
Assert(desiredOverflowBytes >= 0);
}
ao_attr->overflowSize = desiredOverflowBytes;
}
......
......@@ -1997,7 +1997,7 @@ elog_dismiss(int downgrade_to_elevel)
ErrorData *newedata = &errordata[errordata_stack_depth];
/* errstart has stacked a new ErrorData entry. */
Insist(newedata == edata + 1);
Assert(newedata == edata + 1);
/* It tells us where to send the error report for the new elevel. */
edata->elevel = newedata->elevel;
......
......@@ -326,7 +326,7 @@ remove_segment_config(int16 dbid)
}
systable_endscan(sscan);
Insist(numDel > 0);
Assert(numDel > 0);
heap_close(rel, NoLock);
}
......
......@@ -150,7 +150,7 @@ BitmapDecompress_Decompress(
bitmap[i] = lastBlockData;
break;
default:
Insist(0);
elog(ERROR, "Invalid compression flag");
}
lastBlockData = bitmap[i];
}
......
......@@ -1463,16 +1463,12 @@ SaveMemoryBufToDisk(struct StringInfoData *memoryBuf, char *prefix)
FILE *file = fopen(fileName, "w");
if (file == NULL)
{
elog(ERROR, "Could not write memory usage information. Failed to open file: %s", fileName);
}
uint64 bytes = fwrite(memoryBuf->data, 1, memoryBuf->len, file);
if (bytes != memoryBuf->len)
{
insist_log(false, "Could not write memory usage information. Attempted to write %d", memoryBuf->len);
}
elog(ERROR, "Could not write memory usage information. Attempted to write %d", memoryBuf->len);
fclose(file);
}
......@@ -242,7 +242,7 @@ static void gp_failed_to_alloc(MemoryAllocationStatus ec, int en, int sz)
/* Request 1 MB of waiver for processing error */
VmemTracker_RequestWaiver(1024 * 1024);
Insist(MemoryProtection_IsOwnerThread());
Assert(MemoryProtection_IsOwnerThread());
if (ec == MemoryFailure_QueryMemoryExhausted)
{
elog(LOG, "Logging memory usage for reaching per-query memory limit");
......@@ -267,9 +267,7 @@ static void gp_failed_to_alloc(MemoryAllocationStatus ec, int en, int sz)
elog(LOG, "Logging memory usage for reaching resource group limit");
}
else
{
Assert(!"Unknown memory failure error code");
}
elog(ERROR, "Unknown memory failure error code");
RedZoneHandler_LogVmemUsageOfAllSessions();
MemoryAccounting_SaveToLog();
......
......@@ -413,7 +413,10 @@ LogicalTapeSet *LogicalTapeSetCreate(int ntapes, bool del_on_close)
char tmpprefix[MAXPGPATH];
int len = snprintf(tmpprefix, MAXPGPATH, "slice%d_sort",
currentSliceId);
insist_log(len <= MAXPGPATH - 1, "could not generate temporary file name");
if (len >= MAXPGPATH)
elog(ERROR, "could not generate temporary file name");
StringInfo uniquename = ExecWorkFile_AddUniqueSuffix(tmpprefix);
LogicalTapeSet *lts = LogicalTapeSetCreate_Named(uniquename->data, ntapes, del_on_close);
......
......@@ -3794,7 +3794,8 @@ tuplesort_begin_heap_file_readerwriter(ScanState *ss,
Assert(randomAccess);
int len = snprintf(statedump, sizeof(statedump), "%s_sortstate", rwfile_prefix);
insist_log(len <= MAXPGPATH - 1, "could not generate temporary file name");
if (len >= MAXPGPATH)
elog(ERROR, "could not generate temporary file name");
if(isWriter)
{
......
......@@ -813,14 +813,15 @@ tuplesort_begin_heap_file_readerwriter_mk(ScanState *ss,
int workMem, bool randomAccess)
{
Tuplesortstate_mk *state;
char statedump[MAXPGPATH];
char statedump[MAXPGPATH];
Assert(randomAccess);
int len = snprintf(statedump, sizeof(statedump), "%s_sortstate",
rwfile_prefix);
int len = snprintf(statedump, sizeof(statedump), "%s_sortstate",
rwfile_prefix);
insist_log(len <= MAXPGPATH - 1, "could not generate temporary file name");
if (len >= MAXPGPATH)
elog(ERROR, "could not generate temporary file name");
if (isWriter)
{
......
......@@ -925,7 +925,7 @@ tuplestore_gettuple(Tuplestorestate *state, bool forward,
* word. If seek fails, assume we are at start of file.
*/
insist_log(false, "Backward scanning of tuplestores are not supported at this time");
ereport(ERROR, (errmsg("Backward scanning of tuplestores are not supported at this time")));
if (BufFileSeek(state->myfile, readptr->file, -(long) sizeof(unsigned int),
SEEK_CUR) != 0)
......@@ -1407,9 +1407,7 @@ readtup_heap(Tuplestorestate *state, unsigned int len)
if (BufFileRead(state->myfile, (void *) ((char *) tup + sizeof(uint32)),
tuplen - sizeof(uint32))
!= (size_t) (tuplen - sizeof(uint32)))
{
insist_log(false, "unexpected end of data");
}
elog(ERROR, "unexpected end of data");
}
else
{
......@@ -1419,9 +1417,8 @@ readtup_heap(Tuplestorestate *state, unsigned int len)
if (BufFileRead(state->myfile, (void *) ((char *) tup + sizeof(uint32)),
tuplen - sizeof(uint32))
!= (size_t) (tuplen - sizeof(uint32)))
{
insist_log(false, "unexpected end of data");
}
elog(ERROR, "unexpected end of data");
htup->t_data = (HeapTupleHeader ) ((char *) tup + HEAPTUPLESIZE);
}
......@@ -1430,7 +1427,7 @@ readtup_heap(Tuplestorestate *state, unsigned int len)
if (BufFileRead(state->myfile, (void *) &tuplen,
sizeof(tuplen)) != sizeof(tuplen))
{
insist_log(false, "unexpected end of data");
elog(ERROR, "unexpected end of data");
}
}
......
......@@ -396,10 +396,7 @@ GetRealCmin(TransactionId xmin, CommandId combocid)
if (combocid >= usedComboCids)
{
if (Gp_is_writer)
{
elog(LOG, "writer segworker group unable to resolve visibility %u/%u", combocid, usedComboCids);
Insist(false);
}
ereport(ERROR, (errmsg("writer segworker group unable to resolve visibility %u/%u", combocid, usedComboCids)));
/* We're a reader */
return getSharedComboCidEntry(xmin, combocid, CMIN);
......@@ -414,8 +411,8 @@ GetRealCmax(TransactionId xmin, CommandId combocid)
{
if (combocid >= usedComboCids)
{
insist_log(!Gp_is_writer,
"writer segworker group unable to resolve visibility %u/%u", combocid, usedComboCids);
if (Gp_is_writer)
ereport(ERROR, (errmsg("writer segworker group unable to resolve visibility %u/%u", combocid, usedComboCids)));
/* We're a reader */
return getSharedComboCidEntry(xmin, combocid, CMAX);
......
......@@ -390,9 +390,8 @@ retry:
}
else
{
insist_log(false, "writer segworker group shared snapshot collision on id %d", slotId);
elog(ERROR, "writer segworker group shared snapshot collision on id %d", slotId);
}
/* not reached */
}
if (arrayP->numSlots >= arrayP->maxSlots || arrayP->nextSlot == -1)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册