forked from timescale/timescaledb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Since telemetry job has a special code path to be able to be used both from Apache code and from TSL code, trying to execute the telemetry job with run_job() will fail. This code will allow run_job() to be used with the telemetry job to trigger a send of telemetry data. You have to belong to the group that owns the telemetry job (or be the owner of the telemetry job) to be able to use it. Closes timescale#5605
- Loading branch information
Showing
9 changed files
with
174 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
-- This file and its contents are licensed under the Timescale License. | ||
-- Please see the included NOTICE for copyright information and | ||
-- LICENSE-TIMESCALE for a copy of the license. | ||
\c :TEST_DBNAME :ROLE_SUPERUSER | ||
-- Check that we can use run_job() with the telemetry job, so first | ||
-- locate the job id for it (should be 1, but who knows, and it is not | ||
-- important for this test). | ||
SELECT id AS job_id FROM _timescaledb_config.bgw_job | ||
WHERE proc_schema = '_timescaledb_internal' | ||
AND proc_name = 'policy_telemetry' \gset | ||
-- It should be possible to run it twice and running it should change | ||
-- the last_finish time. Since job_stats can be empty to start with, | ||
-- we run it once first to populate job_stats. | ||
CALL run_job(:job_id); | ||
SELECT last_finish AS last_finish | ||
FROM _timescaledb_internal.bgw_job_stat | ||
WHERE job_id = :job_id \gset | ||
SELECT pg_sleep(1); | ||
pg_sleep | ||
---------- | ||
|
||
(1 row) | ||
|
||
CALL run_job(:job_id); | ||
SELECT last_finish > :'last_finish' AS job_executed, | ||
last_run_success | ||
FROM _timescaledb_internal.bgw_job_stat | ||
WHERE job_id = :job_id; | ||
job_executed | last_run_success | ||
--------------+------------------ | ||
t | t | ||
(1 row) | ||
|
||
-- Running it as the default user should fail since they do not own | ||
-- the job. This should be the case also for the telemetry job, which | ||
-- is a little special. | ||
\c :TEST_DBNAME :ROLE_DEFAULT_PERM_USER | ||
\set ON_ERROR_STOP 0 | ||
CALL run_job(:job_id); | ||
ERROR: insufficient permissions to run job 1 | ||
\set ON_ERROR_STOP 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
-- This file and its contents are licensed under the Timescale License. | ||
-- Please see the included NOTICE for copyright information and | ||
-- LICENSE-TIMESCALE for a copy of the license. | ||
|
||
\c :TEST_DBNAME :ROLE_SUPERUSER | ||
|
||
-- Check that we can use run_job() with the telemetry job, so first | ||
-- locate the job id for it (should be 1, but who knows, and it is not | ||
-- important for this test). | ||
SELECT id AS job_id FROM _timescaledb_config.bgw_job | ||
WHERE proc_schema = '_timescaledb_internal' | ||
AND proc_name = 'policy_telemetry' \gset | ||
|
||
-- It should be possible to run it twice and running it should change | ||
-- the last_finish time. Since job_stats can be empty to start with, | ||
-- we run it once first to populate job_stats. | ||
CALL run_job(:job_id); | ||
|
||
SELECT last_finish AS last_finish | ||
FROM _timescaledb_internal.bgw_job_stat | ||
WHERE job_id = :job_id \gset | ||
SELECT pg_sleep(1); | ||
|
||
CALL run_job(:job_id); | ||
|
||
SELECT last_finish > :'last_finish' AS job_executed, | ||
last_run_success | ||
FROM _timescaledb_internal.bgw_job_stat | ||
WHERE job_id = :job_id; | ||
|
||
-- Running it as the default user should fail since they do not own | ||
-- the job. This should be the case also for the telemetry job, which | ||
-- is a little special. | ||
\c :TEST_DBNAME :ROLE_DEFAULT_PERM_USER | ||
\set ON_ERROR_STOP 0 | ||
CALL run_job(:job_id); | ||
\set ON_ERROR_STOP 1 | ||
|