Skip to content

Commit

Permalink
Ensure TSL library is loaded on database upgrades
Browse files Browse the repository at this point in the history
This patch ensures that the TSL library is loaded when the
database is upgraded and post_update_cagg_try_repair is
called. There are some situations when the library is not
loaded properly (see #4573 and Support-Dev-Collab#468),
resulting in the following error message:

"[..] is not supported under the current "timescale" license
HINT:  Upgrade your license to 'timescale'"
  • Loading branch information
jnidzwetzki committed Aug 18, 2022
1 parent 6beda28 commit e146498
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion src/cross_module_fn.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,33 @@ process_compressed_data_in(PG_FUNCTION_ARGS)
pg_unreachable();
}

/*
* This function ensures that the TSL library is loaded and the call to
* post_update_cagg_try_repair is dispatched to the correct
* function.
*
* The TSL library might not be loaded when post_update_cagg_try_repair is
* called during a database upgrade, resulting in an error message about
* improper licensing:
*
* "[..] is not supported under the current "timescale" license
* INT: Upgrade your license to 'timescale'""
*
* See also the comment about this problem in the function
* process_compressed_data_in.
*/
static Datum
process_cagg_try_repair(PG_FUNCTION_ARGS)
{
ts_license_enable_module_loading();

if (ts_cm_functions->cagg_try_repair != process_cagg_try_repair)
return ts_cm_functions->cagg_try_repair(fcinfo);

error_no_default_fn_pg_community(fcinfo);
pg_unreachable();
}

static void
hypertable_make_distributed_default_fn(Hypertable *ht, List *data_node_names)
{
Expand Down Expand Up @@ -433,7 +460,7 @@ TSDLLEXPORT CrossModuleFunctions ts_cm_functions_default = {
.remote_drop_dist_ht_invalidation_trigger = NULL,
.invalidation_process_hypertable_log = error_no_default_fn_pg_community,
.invalidation_process_cagg_log = error_no_default_fn_pg_community,
.cagg_try_repair = error_no_default_fn_pg_community,
.cagg_try_repair = process_cagg_try_repair,

/* compression */
.compressed_data_send = error_no_default_fn_pg_community,
Expand Down

0 comments on commit e146498

Please sign in to comment.