Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
133 changes: 0 additions & 133 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -694,8 +694,6 @@ enable_option_checking
with_extra_version
with_pg_version_check
enable_coverage
with_libcurl
with_reports_hostname
with_lz4
with_zstd
with_security_flags
Expand Down Expand Up @@ -1329,11 +1327,6 @@ Optional Packages:
append STRING to version
--without-pg-version-check
do not check postgres version during configure
--without-libcurl do not use libcurl for anonymous statistics
collection
--with-reports-hostname=HOSTNAME
Use HOSTNAME as hostname for statistics collection
and update checks
--without-lz4 do not use lz4
--without-zstd do not use zstd
--with-security-flags use security flags
Expand Down Expand Up @@ -4427,132 +4420,6 @@ if test "$enable_coverage" = yes; then
CITUS_LDFLAGS="$CITUS_LDFLAGS --coverage"
fi

#
# libcurl
#



# Check whether --with-libcurl was given.
if test "${with_libcurl+set}" = set; then :
withval=$with_libcurl;
case $withval in
yes)

$as_echo "#define HAVE_LIBCURL 1" >>confdefs.h

;;
no)
:
;;
*)
as_fn_error $? "no argument expected for --with-libcurl option" "$LINENO" 5
;;
esac

else
with_libcurl=yes

$as_echo "#define HAVE_LIBCURL 1" >>confdefs.h

fi



if test "$with_libcurl" = yes; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for curl_global_init in -lcurl" >&5
$as_echo_n "checking for curl_global_init in -lcurl... " >&6; }
if ${ac_cv_lib_curl_curl_global_init+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lcurl $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */

/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char curl_global_init ();
int
main ()
{
return curl_global_init ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_curl_curl_global_init=yes
else
ac_cv_lib_curl_curl_global_init=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curl_curl_global_init" >&5
$as_echo "$ac_cv_lib_curl_curl_global_init" >&6; }
if test "x$ac_cv_lib_curl_curl_global_init" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_LIBCURL 1
_ACEOF

LIBS="-lcurl $LIBS"

else
as_fn_error $? "libcurl not found
If you have libcurl already installed, see config.log for details on the
failure. It is possible the compiler isn't looking in the proper directory.
Use --without-libcurl to disable anonymous statistics collection." "$LINENO" 5
fi

ac_fn_c_check_header_mongrel "$LINENO" "curl/curl.h" "ac_cv_header_curl_curl_h" "$ac_includes_default"
if test "x$ac_cv_header_curl_curl_h" = xyes; then :

else
as_fn_error $? "libcurl header not found
If you have libcurl already installed, see config.log for details on the
failure. It is possible the compiler isn't looking in the proper directory.
Use --without-libcurl to disable libcurl support." "$LINENO" 5
fi


fi

# REPORTS_BASE_URL definition



# Check whether --with-reports-hostname was given.
if test "${with_reports_hostname+set}" = set; then :
withval=$with_reports_hostname;
case $withval in
yes)
as_fn_error $? "argument required for --with-reports-hostname option" "$LINENO" 5
;;
no)
as_fn_error $? "argument required for --with-reports-hostname option" "$LINENO" 5
;;
*)
REPORTS_BASE_URL="https://${withval}"
;;
esac

else
REPORTS_BASE_URL="https://reports.citusdata.com"
fi



cat >>confdefs.h <<_ACEOF
#define REPORTS_BASE_URL "$REPORTS_BASE_URL"
_ACEOF


#
# LZ4
#
Expand Down
27 changes: 0 additions & 27 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -195,33 +195,6 @@ if test "$enable_coverage" = yes; then
CITUS_LDFLAGS="$CITUS_LDFLAGS --coverage"
fi

#
# libcurl
#
PGAC_ARG_BOOL(with, libcurl, yes,
[do not use libcurl for anonymous statistics collection],
[AC_DEFINE([HAVE_LIBCURL], 1, [Define to 1 to build with libcurl support. (--with-libcurl)])])

if test "$with_libcurl" = yes; then
AC_CHECK_LIB(curl, curl_global_init, [],
[AC_MSG_ERROR([libcurl not found
If you have libcurl already installed, see config.log for details on the
failure. It is possible the compiler isn't looking in the proper directory.
Use --without-libcurl to disable anonymous statistics collection.])])
AC_CHECK_HEADER(curl/curl.h, [], [AC_MSG_ERROR([libcurl header not found
If you have libcurl already installed, see config.log for details on the
failure. It is possible the compiler isn't looking in the proper directory.
Use --without-libcurl to disable libcurl support.])])
fi

# REPORTS_BASE_URL definition
PGAC_ARG_REQ(with, reports-hostname, [HOSTNAME],
[Use HOSTNAME as hostname for statistics collection and update checks],
[REPORTS_BASE_URL="https://${withval}"],
[REPORTS_BASE_URL="https://reports.citusdata.com"])
AC_DEFINE_UNQUOTED(REPORTS_BASE_URL, "$REPORTS_BASE_URL",
[Base URL for statistics collection and update checks])

#
# LZ4
#
Expand Down
42 changes: 5 additions & 37 deletions src/backend/distributed/shared_library_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@
#include "distributed/shardsplit_shared_memory.h"
#include "distributed/shared_connection_stats.h"
#include "distributed/shared_library_init.h"
#include "distributed/statistics_collection.h"
#include "distributed/stats/query_stats.h"
#include "distributed/stats/stat_counters.h"
#include "distributed/stats/stat_tenants.h"
Expand Down Expand Up @@ -165,6 +164,7 @@ static char *MitmfifoEmptyString = "";
static bool DeprecatedDeferShardDeleteOnMove = true;
static bool DeprecatedDeferShardDeleteOnSplit = true;
static bool DeprecatedReplicateReferenceTablesOnActivate = false;
static bool DeprecatedEnableStatisticsCollection = false;

/* deprecated GUC value that should not be used anywhere outside this file */
static int ReplicationModel = REPLICATION_MODEL_STREAMING;
Expand Down Expand Up @@ -214,8 +214,6 @@ static bool NodeConninfoGucCheckHook(char **newval, void **extra, GucSource sour
static void NodeConninfoGucAssignHook(const char *newval, void *extra);
static const char * MaxSharedPoolSizeGucShowHook(void);
static const char * LocalPoolSizeGucShowHook(void);
static bool StatisticsCollectionGucCheckHook(bool *newval, void **extra, GucSource
source);
static bool WarnIfLocalExecutionDisabled(bool *newval, void **extra, GucSource source);
static void CitusAuthHook(Port *port, int status);
static bool IsSuperuser(char *userName);
Expand Down Expand Up @@ -1587,21 +1585,13 @@ RegisterCitusConfigVariables(void)

DefineCustomBoolVariable(
"citus.enable_statistics_collection",
gettext_noop("Enables sending basic usage statistics to Citus."),
gettext_noop("Citus uploads daily anonymous usage reports containing "
"rounded node count, shard size, distributed table count, "
"and operating system name. This configuration value controls "
"whether these reports are sent."),
&EnableStatisticsCollection,
#if defined(HAVE_LIBCURL) && defined(ENABLE_CITUS_STATISTICS_COLLECTION)
true,
#else
gettext_noop("Deprecated."),
NULL,
&DeprecatedEnableStatisticsCollection,
false,
#endif
PGC_SIGHUP,
GUC_SUPERUSER_ONLY,
&StatisticsCollectionGucCheckHook,
NULL, NULL);
NULL, NULL, NULL);

DefineCustomBoolVariable(
"citus.enable_unique_job_ids",
Expand Down Expand Up @@ -3212,28 +3202,6 @@ LocalPoolSizeGucShowHook(void)
}


static bool
StatisticsCollectionGucCheckHook(bool *newval, void **extra, GucSource source)
{
#ifdef HAVE_LIBCURL
return true;
#else

/* if libcurl is not installed, only accept false */
if (*newval)
{
GUC_check_errcode(ERRCODE_FEATURE_NOT_SUPPORTED);
GUC_check_errdetail("Citus was compiled without libcurl support.");
return false;
}
else
{
return true;
}
#endif
}


/*
* CitusAuthHook is a callback for client authentication that Postgres provides.
* Citus uses this hook to count the number of active backends.
Expand Down
39 changes: 39 additions & 0 deletions src/backend/distributed/transaction/worker_transaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@

#include "postgres.h"

#include "fmgr.h"
#include "libpq-fe.h"
#include "miscadmin.h"

#include "access/xact.h"
#include "utils/builtins.h"
#include "utils/memutils.h"
#include "utils/uuid.h"

#include "distributed/connection_management.h"
#include "distributed/jsonbutils.h"
Expand All @@ -36,6 +38,10 @@
#include "distributed/worker_manager.h"
#include "distributed/worker_transaction.h"


PG_FUNCTION_INFO_V1(citus_server_id);


static void SendBareCommandListToMetadataNodesInternal(List *commandList,
TargetWorkerSet targetWorkerSet);
static void SendCommandToMetadataWorkersParams(const char *command,
Expand Down Expand Up @@ -836,3 +842,36 @@ IsWorkerTheCurrentNode(WorkerNode *workerNode)

return strcmp(workerServerId, currentServerId) == 0;
}


/*
* citus_server_id returns a random UUID value as server identifier. This is
* modeled after PostgreSQL's pg_random_uuid().
*/
Datum
citus_server_id(PG_FUNCTION_ARGS)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved from src/backend/distributed/utils/statistics_collection.c as is

{
uint8 *buf = (uint8 *) palloc(UUID_LEN);

/*
* If pg_strong_random() fails, fall-back to using random(). In previous
* versions of postgres we don't have pg_strong_random(), so use it by
* default in that case.
*/
if (!pg_strong_random((char *) buf, UUID_LEN))
{
for (int bufIdx = 0; bufIdx < UUID_LEN; bufIdx++)
{
buf[bufIdx] = (uint8) (random() & 0xFF);
}
}

/*
* Set magic numbers for a "version 4" (pseudorandom) UUID, see
* http://tools.ietf.org/html/rfc4122#section-4.4
*/
buf[6] = (buf[6] & 0x0f) | 0x40; /* "version" field */
buf[8] = (buf[8] & 0x3f) | 0x80; /* "variant" field */

PG_RETURN_UUID_P((pg_uuid_t *) buf);
}
Loading