提交 ba66a4a9 编写于 作者: A Ashwin Agrawal

Remove the --enable-testutils config option and code.

Compilation with --enable-testutils seems to has been broken long time
as `MaxDynamicLWLock` is no more defined. Given no one complained
seems this is unused config option and code. Hence, instead of fixing
the compilation ripping out this code.
上级 2d8ca955
......@@ -34,7 +34,7 @@ The python-devel is not required here because it is provided by Anaconda.
## Download and build GPDB
git clone https://github.com/greenplum-db/gpdb.git
cd gpdb
./configure --prefix=`pwd`/greenplumdb --with-gssapi --with-pgport=5432 --with-libedit-preferred --with-perl --with-python --with-openssl --with-libxml --enable-cassert --enable-debug --enable-testutils --enable-depend
./configure --prefix=`pwd`/greenplumdb --with-gssapi --with-pgport=5432 --with-libedit-preferred --with-perl --with-python --with-openssl --with-libxml --enable-cassert --enable-debug --enable-depend
make install
Make sure "--with-python" parameter exists. Because the default Python is the Anaconda Python, It's done.
......
......@@ -863,7 +863,6 @@ with_CC
enable_depend
enable_cassert
enable_debugntuplestore
enable_testutils
enable_orca
enable_mapreduce
enable_gpcloud
......@@ -1548,7 +1547,6 @@ Optional Features:
--enable-cassert enable assertion checks (for debugging)
--enable-debugntuplestore
enable debug_ntuplestore (for debugging)
--enable-testutils enable testing utilities
--disable-orca disable ORCA optimizer
--enable-mapreduce enable Greenplum Mapreduce support
--disable-gpcloud disable gpcloud support
......@@ -6515,35 +6513,6 @@ fi
#
# Enable testing utilities
#
# Check whether --enable-testutils was given.
if test "${enable_testutils+set}" = set; then :
enableval=$enable_testutils;
case $enableval in
yes)
$as_echo "#define USE_TEST_UTILS 1" >>confdefs.h
;;
no)
:
;;
*)
as_fn_error $? "no argument expected for --enable-testutils option" "$LINENO" 5
;;
esac
else
enable_testutils=no
fi
#
# Enable Greenplum ORCA optimizer
#
......
......@@ -796,13 +796,6 @@ PGAC_ARG_BOOL(enable, debugntuplestore, no, [enable debug_ntuplestore (for debug
[AC_DEFINE([USE_DEBUG_NTUPLESTORE], 1,
[Define to 1 to build with debug_ntuplestore. (--enable-ntuplestore)])])
#
# Enable testing utilities
#
PGAC_ARG_BOOL(enable, testutils, no, [enable testing utilities],
[AC_DEFINE([USE_TEST_UTILS], 1,
[Define to 1 to build with testing utilities. (--enable-testutils)])])
#
# Enable Greenplum ORCA optimizer
#
......
......@@ -1999,29 +1999,6 @@ static void syslogger_handle_chunk(PipeProtoChunk *chunk)
PipeProtoChunk *first = NULL;
PipeProtoChunk *prev = NULL;
#ifdef USE_TEST_UTILS
if (chunk->hdr.log_format == 'X')
{
if (chunk->hdr.log_line_number == 1)
{
proc_exit(1);
}
else if (chunk->hdr.log_line_number == 2)
{
proc_exit(2);
}
else if (chunk->hdr.log_line_number == 11)
{
*(int *) 0 = 1234;
}
else
{
abort();
}
return;
}
#endif
Assert(chunk->hdr.log_format == 'c' || chunk->hdr.log_format == 't');
/* I am the last, so chain no one */
......
......@@ -826,14 +826,6 @@ LockAcquireExtended(const LOCKTAG *locktag,
return LOCKACQUIRE_ALREADY_HELD;
}
#ifdef USE_TEST_UTILS_X86
if (gp_test_deadlock_hazard && !dontWait)
{
/* blocking lock request, check if any lightweight lock is already held */
LWLockHeldDetect(locktag, lockmode);
}
#endif /* USE_TEST_UTILS_X86 */
/*
* lockHolder is the gang member that should hold and manage locks for this
* transaction. In Utility mode, or on the QD, it's allways myself.
......
......@@ -89,11 +89,6 @@ static int num_held_lwlocks = 0;
static LWLock *held_lwlocks[MAX_SIMUL_LWLOCKS];
static bool held_lwlocks_exclusive[MAX_SIMUL_LWLOCKS];
#ifdef USE_TEST_UTILS_X86
static void *held_lwlocks_addresses[MAX_SIMUL_LWLOCKS][MAX_FRAME_DEPTH];
static int32 held_lwlocks_depth[MAX_SIMUL_LWLOCKS];
#endif /* USE_TEST_UTILS_X86 */
static int lock_addin_request = 0;
static bool lock_addin_request_allowed = true;
......@@ -706,12 +701,6 @@ LWLockAcquireCommon(LWLock *l, LWLockMode mode, uint64 *valptr, uint64 val)
TRACE_POSTGRESQL_LWLOCK_ACQUIRE(T_NAME(l), T_ID(l), mode);
#ifdef USE_TEST_UTILS_X86
/* keep track of stack trace where lock got acquired */
held_lwlocks_depth[num_held_lwlocks] =
gp_backtrace(held_lwlocks_addresses[num_held_lwlocks], MAX_FRAME_DEPTH);
#endif /* USE_TEST_UTILS_X86 */
/* Add lock to list of locks held by this backend */
held_lwlocks_exclusive[num_held_lwlocks] = (mode == LW_EXCLUSIVE);
held_lwlocks[num_held_lwlocks++] = l;
......@@ -788,12 +777,6 @@ LWLockConditionalAcquire(LWLock *l, LWLockMode mode)
}
else
{
#ifdef USE_TEST_UTILS_X86
/* keep track of stack trace where lock got acquired */
held_lwlocks_depth[num_held_lwlocks] =
gp_backtrace(held_lwlocks_addresses[num_held_lwlocks], MAX_FRAME_DEPTH);
#endif /* USE_TEST_UTILS_X86 */
/* Add lock to list of locks held by this backend */
held_lwlocks_exclusive[num_held_lwlocks] = (mode == LW_EXCLUSIVE);
held_lwlocks[num_held_lwlocks++] = l;
......@@ -1213,25 +1196,11 @@ LWLockRelease(LWLock *l)
{
held_lwlocks_exclusive[i] = held_lwlocks_exclusive[i + 1];
held_lwlocks[i] = held_lwlocks[i + 1];
#ifdef USE_TEST_UTILS_X86
/* shift stack traces */
held_lwlocks_depth[i] = held_lwlocks_depth[i + 1];
memcpy
(
held_lwlocks_addresses[i],
held_lwlocks_addresses[i + 1],
held_lwlocks_depth[i] * sizeof(*held_lwlocks_depth)
)
;
#endif /* USE_TEST_UTILS_X86 */
}
// Clear out old last entry.
held_lwlocks_exclusive[num_held_lwlocks] = false;
held_lwlocks[num_held_lwlocks] = 0;
#ifdef USE_TEST_UTILS_X86
held_lwlocks_depth[num_held_lwlocks] = 0;
#endif /* USE_TEST_UTILS_X86 */
/* Acquire mutex. Time spent holding mutex should be short! */
SpinLockAcquire(&lock->mutex);
......@@ -1400,111 +1369,3 @@ LWLockHeldExclusiveByMe(LWLockId lockid)
}
return false;
}
#ifdef USE_TEST_UTILS_X86
/*
* Return number of locks held by my process
*/
uint32
LWLocksHeld()
{
Assert(num_held_lwlocks >= 0);
uint32 locks = 0, i = 0;
for (i = 0; i < num_held_lwlocks; i++)
{
if (LWLOCK_IS_PREDEFINED(held_lwlocks[i]))
{
locks++;
}
}
return locks;
}
/*
* Get lock id of the most lately acquired lwlock
*/
LWLockId
LWLockHeldLatestId()
{
Assert(num_held_lwlocks > 0);
uint32 i = 0;
for (i = num_held_lwlocks; i > 0; i--)
{
if (LWLOCK_IS_PREDEFINED(held_lwlocks[i - 1]))
{
return held_lwlocks[i - 1];
}
}
Assert(!"No predefined lwlock held");
return MaxDynamicLWLock;
}
/*
* Get caller address for the most lately acquired lwlock
*/
void *
LWLockHeldLatestCaller()
{
Assert(num_held_lwlocks > 0);
uint32 i = 0;
for (i = num_held_lwlocks; i > 0; i--)
{
if (LWLOCK_IS_PREDEFINED(held_lwlocks[i - 1]))
{
return held_lwlocks_addresses[i - 1][1];
}
}
return 0;
}
/*
* Build string containing stack traces where all exclusively-held
* locks were acquired;
*/
const char*
LWLocksHeldStackTraces()
{
if (num_held_lwlocks == 0)
{
return NULL;
}
StringInfo append = makeStringInfo(); /* palloc'd */
uint32 i = 0, cnt = 1;
/* append stack trace for each held lock */
for (i = 0; i < num_held_lwlocks; i++)
{
if (!LWLOCK_IS_PREDEFINED(held_lwlocks[i]))
{
continue;
}
appendStringInfo(append, "%d: LWLock %d:\n", cnt++, held_lwlocks[i] );
char *stackTrace =
gp_stacktrace(held_lwlocks_addresses[i], held_lwlocks_depth[i]);
Assert(stackTrace != NULL);
appendStringInfoString(append, stackTrace);
pfree(stackTrace);
}
Assert(append->len > 0);
return append->data;
}
#endif /* USE_TEST_UTILS_X86 */
......@@ -5157,11 +5157,6 @@ PostgresMain(int argc, char *argv[],
*/
DoingCommandRead = true;
#ifdef USE_TEST_UTILS
/* reset time slice */
TimeSliceReset();
#endif /* USE_TEST_UTILS */
/*
* (2b) Check for temp table delete reset session work.
* Also clean up idle resources.
......
......@@ -19,7 +19,7 @@ override CPPFLAGS := -I. -I$(srcdir) $(CPPFLAGS)
OBJS = guc.o help_config.o pg_rusage.o ps_status.o rbtree.o \
gpexpand.o \
faultinjector.o testutils.o uriparser.o \
faultinjector.o uriparser.o \
bitstream.o bitmap_compression.o guc_gp.o backend_cancel.o \
superuser.o timeout.o tzparser.o
......
......@@ -226,15 +226,6 @@ int gp_perfmon_segment_interval;
/* Perfmon debug GUC */
bool gp_perfmon_print_packet_info;
/* time slice enforcement */
bool gp_test_time_slice;
int gp_test_time_slice_interval;
int gp_test_time_slice_report_level = ERROR;
/* database-lightweight lock hazard detection */
bool gp_test_deadlock_hazard;
int gp_test_deadlock_hazard_report_level = ERROR;
bool vmem_process_interrupt = false;
bool execute_pruned_plan = false;
......@@ -551,16 +542,6 @@ static const struct config_enum_entry gp_gpperfmon_log_alert_level[] = {
{NULL, 0}
};
static const struct config_enum_entry test_time_slice_report_level_options[] = {
{"notice", NOTICE},
{"warning", WARNING},
{"error", ERROR},
{"log", LOG},
{"fatal", FATAL},
{"panic", PANIC},
{NULL, 0}
};
static const struct config_enum_entry password_hash_algorithm_options[] = {
/* {"none", PASSWORD_HASH_NONE}, * this option is not exposed */
{"MD5", PASSWORD_HASH_MD5},
......@@ -1789,28 +1770,6 @@ struct config_bool ConfigureNamesBool_gp[] =
NULL, NULL, NULL
},
{
{"gp_test_time_slice", PGC_USERSET, GP_ERROR_HANDLING,
gettext_noop("Check for time slice violation between checks for interrupts"),
NULL,
GUC_NO_SHOW_ALL | GUC_NOT_IN_SAMPLE | GUC_GPDB_ADDOPT
},
&gp_test_time_slice,
false,
NULL, NULL, NULL
},
{
{"gp_test_deadlock_hazard", PGC_USERSET, GP_ERROR_HANDLING,
gettext_noop("Check if a lightweight lock is already held when requesting a database lock"),
NULL,
GUC_NO_SHOW_ALL | GUC_NOT_IN_SAMPLE | GUC_GPDB_ADDOPT
},
&gp_test_deadlock_hazard,
false,
NULL, NULL, NULL
},
{
{"gp_partitioning_dynamic_selection_log", PGC_USERSET, DEVELOPER_OPTIONS,
gettext_noop("Print out debugging info for GPDB dynamic partition selection"),
......@@ -3951,17 +3910,6 @@ struct config_int ConfigureNamesInt_gp[] =
NULL, NULL, NULL
},
{
{"gp_test_time_slice_interval", PGC_USERSET, GP_ERROR_HANDLING,
gettext_noop("Maximum interval in ms between successive checks for interrupts."),
NULL,
GUC_NO_SHOW_ALL | GUC_NOT_IN_SAMPLE | GUC_GPDB_ADDOPT
},
&gp_test_time_slice_interval,
1000, 1, 10000,
NULL, NULL, NULL
},
{
{"gp_resqueue_memory_policy_auto_fixed_mem", PGC_USERSET, RESOURCES_MEM,
gettext_noop("Sets the fixed amount of memory reserved for non-memory intensive operators in the AUTO policy."),
......@@ -4527,28 +4475,6 @@ struct config_enum ConfigureNamesEnum_gp[] =
NULL, NULL, NULL
},
{
{"gp_test_time_slice_report_level", PGC_USERSET, LOGGING_WHEN,
gettext_noop("Sets the message level for time slice violation reports."),
gettext_noop("Valid values are NOTICE, WARNING, ERROR, FATAL and PANIC."),
GUC_GPDB_ADDOPT | GUC_NO_SHOW_ALL | GUC_NOT_IN_SAMPLE
},
&gp_test_time_slice_report_level,
ERROR, test_time_slice_report_level_options,
NULL, NULL, NULL
},
{
{"gp_test_deadlock_hazard_report_level", PGC_USERSET, LOGGING_WHEN,
gettext_noop("Sets the message level for deadlock hazard reports."),
gettext_noop("Valid values are NOTICE, WARNING, ERROR, FATAL and PANIC."),
GUC_GPDB_ADDOPT | GUC_NO_SHOW_ALL | GUC_NOT_IN_SAMPLE
},
&gp_test_deadlock_hazard_report_level,
ERROR, server_message_level_options,
NULL, NULL, NULL
},
{
{"gp_log_format", PGC_POSTMASTER, LOGGING_WHERE,
gettext_noop("Sets the format for log files."),
......
/*-------------------------------------------------------------------------
*
* testutils.c
* Implementation of testing utilities.
*
* Portions Copyright (c) 2010, Greenplum inc
* Portions Copyright (c) 2012-Present Pivotal Software, Inc.
*
*
* IDENTIFICATION
* src/backend/utils/misc/testutils.c
*
*-------------------------------------------------------------------------
*/
#include <sys/time.h>
#include <sys/resource.h>
#include "postgres.h"
#include "storage/lock.h"
#include "storage/lwlock.h"
#include "utils/elog.h"
#include "utils/testutils.h"
#ifdef USE_TEST_UTILS
#define MAX_FRAME_DEPTH 64
#define USECS_IN_MSEC 1000
#define MSECS_IN_SEC 1000
/* holds return addresses of frames in stack */
static void *stackAddressesLastCFI[MAX_FRAME_DEPTH];
/* stack depth */
static uint32 stackDepthLastCFI = 0;
/* elapsed user time */
static struct timeval userTimeLastCFI;
/* static functions */
static int32 timeElapsedMs(struct timeval *tvLast, struct timeval *tvFirst);
static bool IsValidReportLevel(int level);
/*
* Reset time slice
*/
void
TimeSliceReset()
{
struct rusage ru;
if (0 != getrusage(RUSAGE_SELF, &ru))
{
elog(ERROR, "Time slicer: Failed to retrieve user time");
}
userTimeLastCFI = ru.ru_utime;
stackDepthLastCFI = gp_backtrace(stackAddressesLastCFI, MAX_FRAME_DEPTH);
}
/*
* Check if time slice since last check-for-interrupts (CFI) has been exceeded
*/
void
TimeSliceCheck(const char *file, int line)
{
struct rusage ru;
int32 elapsedMs = 0;
/* CFI is disabled inside critical sections */
if (0 != InterruptHoldoffCount || 0 != CritSectionCount)
{
return;
}
/* get current user time */
if (getrusage(RUSAGE_SELF, &ru) != 0)
{
elog(ERROR, "Time slicer: Failed to retrieve user time");
}
elapsedMs = timeElapsedMs(&ru.ru_utime, &userTimeLastCFI);
/* check elapsed time since last CFI */
if (gp_test_time_slice_interval < elapsedMs)
{
void *stackAddressesCurrent[MAX_FRAME_DEPTH];
uint32 stackDepthCurrent = gp_backtrace(stackAddressesCurrent, MAX_FRAME_DEPTH);
char *stackTraceLastCFI = gp_stacktrace(stackAddressesLastCFI, stackDepthLastCFI);
char *stackTraceCurrent = gp_stacktrace(stackAddressesCurrent, stackDepthCurrent);
/* report time slice violation error */
ereport(gp_test_time_slice_report_level,
(errmsg("Time slice of %d ms exceeded at (%s:%d), last CFI before %d ms)",
gp_test_time_slice_interval,
file,
line,
elapsedMs),
errdetail("Stack trace of last CFI:\n%s\nCurrent stack trace:\n%s\n",
stackTraceLastCFI,
stackTraceCurrent)));
/*
* If gp_test_time_slice_report_level is set to a lower elevel than
* ERROR we need to free the stacktrace to avoid leaking here, else
* the error handling will take care of it for us.
*/
pfree(stackTraceLastCFI);
pfree(stackTraceCurrent);
}
/* reset time slice */
userTimeLastCFI = ru.ru_utime;
stackDepthLastCFI = gp_backtrace(stackAddressesLastCFI, MAX_FRAME_DEPTH);
}
/*
* Get elapsed time between two timestamps in ms
*/
static int32
timeElapsedMs(struct timeval *tvLast, struct timeval *tvFirst)
{
return (tvLast->tv_sec - tvFirst->tv_sec) * MSECS_IN_SEC +
(tvLast->tv_usec - tvFirst->tv_usec) / USECS_IN_MSEC;
}
/*
* Check if report level is valid
*/
static bool
IsValidReportLevel(int level)
{
return (level >= NOTICE && level <= PANIC);
}
#ifdef USE_TEST_UTILS_X86
/*
* check if lightweight lock(s) are held;
* print stack trace where lock(s) got acquired and error out;
*/
void
LWLockHeldDetect(const void *pv, int lockmode)
{
Assert(gp_test_deadlock_hazard);
Assert(IsValidReportLevel(gp_test_deadlock_hazard_report_level));
const LOCKTAG *locktag = (const LOCKTAG *) pv;
if (0 < LWLocksHeld())
{
void *stackAddressesCurrent[MAX_FRAME_DEPTH];
uint32 stackDepthCurrent = gp_backtrace(stackAddressesCurrent, MAX_FRAME_DEPTH);
char *stackTraceCurrent = gp_stacktrace(stackAddressesCurrent, stackDepthCurrent);
const char *stackTraces = LWLocksHeldStackTraces();
Assert(NULL != stackTraces);
/* report time slice violation error */
ereport(gp_test_deadlock_hazard_report_level,
(errmsg("Attempting to acquire database lock (%s:%d:%d:%d:%d) while holding lightweight lock (%d:%p).\n"
"Stack trace(s) where lightweight lock(s) got acquired:\n%s\n"
"Current stack trace:\n%s\n",
GetLockmodeName(locktag->locktag_lockmethodid, lockmode),
locktag->locktag_field1,
locktag->locktag_field2,
locktag->locktag_field3,
locktag->locktag_field4,
LWLockHeldLatestId(),
LWLockHeldLatestCaller(),
stackTraces,
stackTraceCurrent)));
}
}
#endif /* USE_TEST_UTILS_X86 */
#endif /* USE_TEST_UTILS */
/* EOF */
......@@ -135,30 +135,14 @@ BackoffBackendTick(void)
#ifndef WIN32
#ifdef USE_TEST_UTILS
#define CHECK_FOR_INTERRUPTS() \
do { \
if (gp_test_time_slice) \
{ \
CHECK_TIME_SLICE(); \
} \
\
if (InterruptPending) \
ProcessInterrupts(__FILE__, __LINE__); \
BackoffBackendTick(); \
ReportOOMConsumption(); \
RedZoneHandler_DetectRunawaySession();\
} while(0)
#else
#define CHECK_FOR_INTERRUPTS() \
do { \
if (InterruptPending) \
ProcessInterrupts(__FILE__, __LINE__); \
BackoffBackendTick(); \
ReportOOMConsumption(); \
RedZoneHandler_DetectRunawaySession();\
} while(0)
#endif /* USE_TEST_UTILS */
#else /* WIN32 */
......
......@@ -981,9 +981,6 @@
/* Define to select SysV-style shared memory. */
#undef USE_SYSV_SHARED_MEMORY
/* Define to 1 to build with testing utilities. (--enable-testutils) */
#undef USE_TEST_UTILS
/* Define to select unnamed POSIX semaphores. */
#undef USE_UNNAMED_POSIX_SEMAPHORES
......
......@@ -53,7 +53,6 @@ extern "C" {
#include "utils/elog.h"
#include "utils/palloc.h"
#include "storage/itemptr.h"
#include "utils/testutils.h"
/* ----------------------------------------------------------------
* Section 1: variable-length datatypes (TOAST support)
......
......@@ -214,14 +214,6 @@ extern void LWLockReleaseAll(void);
extern bool LWLockHeldByMe(LWLock *lock);
extern bool LWLockHeldExclusiveByMe(LWLock *lock);
#ifdef USE_TEST_UTILS_X86
// GPDB_94_MERGE_FIXME: do these still work? Are they still needed?
extern uint32 LWLocksHeld(void);
extern LWLock *LWLockHeldLatest(void);
extern void *LWLockHeldLatestCaller(void);
extern const char *LWLocksHeldStackTraces(void);
#endif /* USE_TEST_UTILS_X86 */
extern bool LWLockAcquireWithVar(LWLock *lock, uint64 *valptr, uint64 val);
extern bool LWLockWaitForVar(LWLock *lock, uint64 *valptr, uint64 oldval, uint64 *newval);
extern void LWLockUpdateVar(LWLock *lock, uint64 *valptr, uint64 value);
......
/*-------------------------------------------------------------------------
*
* testutils.h
* Collection of testing utilities.
*
* Portions Copyright (c) 2010, Greenplum inc
* Portions Copyright (c) 2012-Present Pivotal Software, Inc.
*
*
* IDENTIFICATION
* src/include/utils/testutils.h
*
*-------------------------------------------------------------------------
*/
#ifndef TESTUTILS_H_
#define TESTUTILS_H_
#ifdef USE_TEST_UTILS
/* external variables */
extern PGDLLIMPORT volatile int32 InterruptHoldoffCount;
extern PGDLLIMPORT volatile int32 CritSectionCount;
/* time slicing */
extern void TimeSliceReset(void);
extern void TimeSliceCheck(const char *file, int line);
#define CHECK_TIME_SLICE() TimeSliceCheck(__FILE__, __LINE__)
#if defined(__i386) || defined(__x86_64__)
#define USE_TEST_UTILS_X86 1
/* detect database-lightweight lock conflict */
extern void LWLockHeldDetect(const void *locktag, int lockmode);
#endif /* defined(__i386) || defined(__x86_64__) */
/* GUCs */
extern bool gp_test_time_slice; /* session GUC, controls time slice violation checking */
extern int gp_test_time_slice_interval; /* session GUC, sets time slice interval in ms */
extern int gp_test_time_slice_report_level;
/* session GUC, sets level of violation report messages */
extern bool gp_test_deadlock_hazard; /* session GUC, controls database-lightweight lock conflict detection */
extern int gp_test_deadlock_hazard_report_level;
/* session GUC, sets level of hazard report messages */
#endif /* USE_TEST_UTILS */
#endif /* TESTUTILS_H_ */
/* EOF */
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册