Compare commits

...

4 Commits

Author SHA1 Message Date
Alex Chi Z
1060520830 assume primary is the default
Signed-off-by: Alex Chi Z <chi@neon.tech>
2025-03-17 16:36:01 -04:00
Alex Chi Z
4077eeecaa resolve comments
Signed-off-by: Alex Chi Z <chi@neon.tech>
2025-03-13 16:52:20 -04:00
Alex Chi Z
b86c4fabb4 embed everything into application_name, finish storage-side code
Signed-off-by: Alex Chi Z <chi@neon.tech>
2025-03-11 17:28:47 -04:00
Alex Chi Z
4d99b0df58 feat(compute_ctl): pass compute type to pageserver
Signed-off-by: Alex Chi Z <chi@neon.tech>
2025-03-11 16:29:24 -04:00
4 changed files with 63 additions and 2 deletions

View File

@@ -855,6 +855,12 @@ impl ComputeNode {
info!("Storage auth token not set");
}
if let Some(spec) = &compute_state.pspec {
config.application_name(&format!("compute_ctl-{}", spec.spec.mode.to_type_str()));
} else {
config.application_name("compute_ctl");
}
// Connect to pageserver
let mut client = config.connect(NoTls)?;
let pageserver_connect_micros = start_time.elapsed().as_micros() as u64;

View File

@@ -99,6 +99,7 @@ pub fn write_postgres_conf(
writeln!(file, "lc_numeric='C.UTF-8'")?;
}
writeln!(file, "neon.endpoint_type={}", spec.mode.to_type_str())?;
match spec.mode {
ComputeMode::Primary => {}
ComputeMode::Static(lsn) => {

View File

@@ -272,6 +272,18 @@ pub enum ComputeMode {
Replica,
}
impl ComputeMode {
/// Convert the compute mode to a string that can be used to identify the type of compute,
/// which means that if it's a static compute, the LSN will not be included.
pub fn to_type_str(&self) -> &'static str {
match self {
ComputeMode::Primary => "primary",
ComputeMode::Static(_) => "static",
ComputeMode::Replica => "replica",
}
}
}
/// Log level for audit logging
/// Disabled, log, hipaa
/// Default is Disabled

View File

@@ -50,6 +50,20 @@
#define MIN_RECONNECT_INTERVAL_USEC 1000
#define MAX_RECONNECT_INTERVAL_USEC 1000000
enum NeonEndpointType {
EP_TYPE_PRIMARY = 1,
EP_TYPE_REPLICA,
EP_TYPE_STATIC
};
static const struct config_enum_entry neon_endpoint_types[] = {
{"primary", EP_TYPE_PRIMARY, false},
{"replica", EP_TYPE_REPLICA, false},
{"static", EP_TYPE_STATIC, false},
{NULL, 0, false}
};
/* GUCs */
char *neon_timeline;
char *neon_tenant;
@@ -62,6 +76,8 @@ int flush_every_n_requests = 8;
int neon_protocol_version = 2;
static int neon_endpoint_type = 0;
static int max_reconnect_attempts = 60;
static int stripe_size;
@@ -392,7 +408,7 @@ pageserver_connect(shardno_t shard_no, int elevel)
{
const char *keywords[4];
const char *values[4];
char pid_str[16];
char pid_str[24];
int n_pgsql_params;
TimestampTz now;
int64 us_since_last_attempt;
@@ -445,7 +461,22 @@ pageserver_connect(shardno_t shard_no, int elevel)
*/
keywords[n_pgsql_params] = "application_name";
{
int ret = snprintf(pid_str, sizeof(pid_str), "%d", MyProcPid);
int ret;
switch (neon_endpoint_type)
{
case EP_TYPE_PRIMARY:
ret = snprintf(pid_str, sizeof(pid_str), "%d-%s", MyProcPid, "primary");
break;
case EP_TYPE_REPLICA:
ret = snprintf(pid_str, sizeof(pid_str), "%d-%s", MyProcPid, "replica");
break;
case EP_TYPE_STATIC:
ret = snprintf(pid_str, sizeof(pid_str), "%d-%s", MyProcPid, "static");
break;
default:
ret = snprintf(pid_str, sizeof(pid_str), "%d", MyProcPid);
break;
}
if (ret < 0 || ret >= (int)(sizeof(pid_str)))
elog(FATAL, "stack-allocated buffer too small to hold pid");
}
@@ -1370,6 +1401,17 @@ pg_init_libpagestore(void)
GUC_UNIT_MS,
NULL, NULL, NULL);
DefineCustomEnumVariable(
"neon.endpoint_type",
"The compute endpoint node type",
NULL,
&neon_endpoint_type,
EP_TYPE_PRIMARY,
neon_endpoint_types,
PGC_POSTMASTER,
0,
NULL, NULL, NULL);
relsize_hash_init();
if (page_server != NULL)