Skip to content

Commit 036d342

Browse files
yugabyte-cijaki
authored andcommitted
[BACKPORT pg15-cherrypicks] all: Bulk port from master - 68
Summary: 66890cb [PLAT-14781] Add runtime config for download metrics as pdf b2f24f2 [#9797] YSQL: Stubs for ysql major version upgrade RPCs 5891faa [#23332] Docdb: Fix yb-admin to handle snapshot_retention correctly 0614c52 [PLAT-14756] Releases API RBAC cleanup 2cfb999 [docs] Release notes for 2024.1.1.0-b137 (#23185) d868a03 [PLAT-13495] Do not run dual nic steps on systemd upgrade 10bc447 [PLAT-14798] Adding internal load balancer to devspace 7296df8 [docs] [2.23] Add pg_cron extension docs (#22546) 79902ae [PLAT-14678] - feat : Export All Metrics to pdf 8a0b95c [#23322] YSQL: pg_partman: fix logic of checking existing table Excluded: 63f471a [#18822] YSQL: Framework to skip redundant sec index updates and fkey checks when relevant columns not modified 3040472 [PLAT-14783] [PGParity] After Edit RR cores scale up on PG Parity enabled cluster, the RR node does not have PGP gflags e052089 [PLAT-14774] Per process tserver metrics is not working if YSQL is disabled 0c664a1 [#22370] docdb: Cost Based Optimizer changes to take into account backward scans improvement a060877 [PLAT-13712]fix plan info for Azure VMs 291dd40 Remove 6sense domains from CSP headers (#23354) 75cb273 [#23330] docdb: fixed static columns handling for CQL operations Test Plan: Jenkins: rebase: pg15-cherrypicks Reviewers: jason, tfoucher Tags: #jenkins-ready Differential Revision: https://phorge.dev.yugabyte.com/D36984
1 parent 1841718 commit 036d342

File tree

50 files changed

+2720
-379
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+2720
-379
lines changed

.github/vale-styles/Yugabyte/spelling-exceptions.txt

+1
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,7 @@ Patroni
445445
performant
446446
PgBouncer
447447
pgLoader
448+
pg_cron
448449
pg_recvlogical
449450
Phabricator
450451
phaser

docs/content/preview/architecture/docdb-replication/async-replication.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -161,12 +161,11 @@ Today, this is done by backing up the source universe and restoring it to the ta
161161

162162
Ongoing work, [#17862](https://github.com/yugabyte/yugabyte-db/issues/17862), will replace using backup and restore here with directly copying RocksDB files between the source and target universes. This will be more performant and flexible and remove the need for external storage like S3 to set up replication.
163163

164-
165164
## Supported deployment scenarios
166165

167166
xCluster currently supports active-active single-master and active-active multi-master deployments.
168167

169-
### Active- active single-master
168+
### Active-active single-master
170169

171170
Here the replication is unidirectional from a source universe to a target universe. The target universe is typically located in data centers or regions that are different from the source universe. The source universe can serve both reads and writes. The target universe can only serve reads. Since only the nodes in one universe can take writes this mode is referred to as single master. Note that within the source universe all nodes can serve writes.
172171

docs/content/preview/explore/ysql-language-features/pg-extensions/_index.md

+1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ YugabyteDB supports the following additional extensions, some of which you must
5959
| [HypoPG](extension-hypopg/) | Pre-bundled | Create hypothetical indexes to test whether an index can increase performance for problematic queries without consuming any actual resources. |
6060
| Orafce | Pre-bundled | Provides compatibility with Oracle functions and packages that are either missing or implemented differently in YugabyteDB and PostgreSQL. This compatibility layer can help you port your Oracle applications to YugabyteDB.<br/>For more information, see the [Orafce](https://github.com/orafce/orafce) documentation. |
6161
| [PGAudit](../../../secure/audit-logging/audit-logging-ysql/) | Pre-bundled | The PostgreSQL Audit Extension (pgaudit) provides detailed session and/or object audit logging via the standard PostgreSQL logging facility. |
62+
| [pg_cron](extension-pgcron/) | Pre-bundled | Provides a cron-based job scheduler that runs inside the database. |
6263
| [pg_hint_plan](../../query-1-performance/pg-hint-plan/#root) | Pre-bundled | Tweak execution plans using "hints", which are descriptions in the form of SQL comments.<br/>For more information, see the [pg_hint_plan](https://pghintplan.osdn.jp/pg_hint_plan.html) documentation. |
6364
| pg_stat_monitor | Pre-bundled | A PostgreSQL query performance monitoring tool, based on the PostgreSQL pg_stat_statements module.<br/>For more information, see the [pg_stat_monitor](https://docs.percona.com/pg-stat-monitor/index.html) documentation. |
6465
| [pgvector](extension-pgvector) | Pre-bundled | Allows you to store and query vectors, for use in vector similarity searching. |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
---
2+
title: pg_cron extension
3+
headerTitle: pg_cron extension
4+
linkTitle: pg_cron
5+
description: Using the pg_cron extension in YugabyteDB
6+
techPreview: /preview/releases/versioning/#feature-availability
7+
menu:
8+
preview:
9+
identifier: extension-pgcron
10+
parent: pg-extensions
11+
weight: 20
12+
type: docs
13+
---
14+
15+
The [pg_cron](https://github.com/citusdata/pg_cron) extension provides a cron-based job scheduler that runs inside the database. It uses the same syntax as regular cron, and allows you to schedule YSQL commands directly from the database. You can also use '[1-59] seconds' to schedule a job based on an interval.
16+
17+
YugabyteDB supports all features of the pg_cron extension. Although YugabyteDB is a distributed database that operates on multiple nodes, pg_cron only runs on one of these nodes, called the pg_cron leader. Only the pg_cron leader schedules and runs the cron jobs. The queries executed by jobs do take advantage of all available resources in the cluster.
18+
19+
If the pg_cron leader node fails, another node is automatically elected as the new leader to ensure it is highly available. This process is transparent, and you can connect to any node in a cluster to schedule jobs.
20+
21+
## Set up pg_cron
22+
23+
pg_cron in YugabyteDB is {{<badge/tp>}}. Before you can use the feature, you must enable it by setting the `enable_pg_cron` flag. To do this, add `enable_pg_cron` to the `allowed_preview_flags_csv` flag and set the `enable_pg_cron` flag to true on all YB-Masters and YB-TServers.
24+
25+
The pg_cron extension is installed on only one database, which stores the extension data. The default cron database is `yugabyte`. You can change it by setting the `ysql_cron_database_name` flag on all YB-TServers. You can create the database after setting the flag.
26+
27+
For example, to create a single-node [yugabyted](../../../../reference/configuration/yugabyted/) cluster with pg_cron on database 'db1', use the following command:
28+
29+
```sh
30+
./bin/yugabyted start --master_flags "allowed_preview_flags_csv={enable_pg_cron},enable_pg_cron=true" --tserver_flags "allowed_preview_flags_csv={enable_pg_cron},enable_pg_cron=true,ysql_cron_database_name=db1" --ui false
31+
```
32+
33+
To change the database after the extension is created, you must first drop the extension and then change the flag value.
34+
35+
## Enable pg_cron
36+
37+
Create the extension as superuser on the cron database.
38+
39+
```sql
40+
CREATE EXTENSION pg_cron;
41+
```
42+
43+
You can grant access to other users to use the extension. For example:
44+
45+
```sql
46+
GRANT USAGE ON SCHEMA cron TO elephant;
47+
```
48+
49+
## Use pg_cron
50+
51+
YugabyteDB supports all features and syntax of the pg_cron extension.
52+
53+
For example, the following command calls a stored procedure every five seconds:
54+
55+
```sql
56+
SELECT cron.schedule('process-updates', '5 seconds', 'CALL process_updates()');
57+
```
58+
59+
If you need to run jobs in multiple databases, use `cron.schedule_in_database()`.
60+
61+
When running jobs, keep in mind the following:
62+
63+
- It may take up to 60 seconds for job changes to get picked up by the pg_cron leader.
64+
- When a new pg_cron leader node is elected, no jobs are run for the first minute. Any job that were in flight on the failed node will not be retried, as their outcome is not known.
65+
66+
For more information on how to schedule jobs, refer to the [pg_cron documentation](https://github.com/yugabyte/yugabyte-db/blob/master/src/postgres/third-party-extensions/pg_cron/README.md).

docs/content/preview/reference/configuration/yb-tserver.md

+8
Original file line numberDiff line numberDiff line change
@@ -855,6 +855,14 @@ Default: `-1` (disables logging statement durations)
855855

856856
Specifies the lowest YSQL message level to log.
857857

858+
##### --ysql_cron_database_name
859+
860+
Specifies the database where pg_cron is to be installed. You can create the database after setting the flag.
861+
862+
The [pg_cron extension](../../../explore/ysql-language-features/pg-extensions/extension-pgcron/) is installed on only one database (by default, `yugabyte`).
863+
864+
To change the database after the extension is created, you must first drop the extension and then change the flag value.
865+
858866
##### --ysql_output_buffer_size
859867

860868
Size of YSQL layer output buffer, in bytes. YSQL buffers query responses in this output buffer until either a buffer flush is requested by the client or the buffer overflows.

0 commit comments

Comments
 (0)