-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add cache-service module; replace minio create bucket bootstrap scrip…
…ts with container entrypoint
- Loading branch information
1 parent
d2b0b54
commit 056d590
Showing
21 changed files
with
296 additions
and
59 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
version: '3.8' | ||
services: | ||
|
||
trino: | ||
environment: | ||
MINITRINO_BOOTSTRAP: bootstrap-trino.sh | ||
volumes: | ||
- ./modules/admin/cache-service/resources/trino/rules.json:/etc/starburst/rules.json | ||
- ./modules/admin/cache-service/resources/trino/cache.properties:/etc/starburst/cache.properties | ||
- ./modules/admin/cache-service/resources/trino/cache_svc.properties:/etc/starburst/catalog/cache_svc.properties | ||
- ./modules/admin/cache-service/resources/trino/hive_mv_tsr.properties:/etc/starburst/catalog/hive_mv_tsr.properties | ||
ports: | ||
- 8180:8180 | ||
|
||
cache-svc-backend: | ||
image: postgres:${POSTGRES_SEP_CACHE_SVC_VER} | ||
container_name: cache-svc-backend | ||
env_file: | ||
- ./modules/admin/cache-service/resources/postgres/cache-svc.env | ||
labels: | ||
- com.starburst.tests=minitrino | ||
- com.starburst.tests.module.cache-service=admin-cache-service |
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,6 @@ | ||
{ | ||
"description": "Cache service module", | ||
"incompatibleModules": [], | ||
"dependentModules": ["hive", "postgres", "insights"], | ||
"enterprise": true | ||
} |
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,31 @@ | ||
# Cache Service Module | ||
|
||
This module configures [Starburst's cache | ||
service](https://docs.starburst.io/latest/admin/cache-service.html) feature | ||
along with basic config for [table scan | ||
redirections](https://docs.starburst.io/latest/admin/cache-service.html#enable-table-scan-redirections) | ||
and [materialized | ||
views](https://docs.starburst.io/latest/connector/starburst-hive.html#materialized-views). | ||
|
||
The module launches with the `postgres`, `hive`, and `insights` modules. | ||
Additional catalogs, `cache_svc` and `hive_mv_tsr`, are also configured. | ||
`cache_svc` exposes the backend database for the cache service for querying in | ||
Starburst, and `hive_mv_tsr` is a clone of the `hive` catalog but with | ||
materialized views and `hive.security=allow-all` enabled. | ||
|
||
For troubleshooting, the bootstrap script enables debug logging for | ||
`com.starburstdata.cache` as well as JMX dump tables for the MBeans associated | ||
with the cache service. The JMX dump tables can be queried in the `jmx.history` | ||
schema. | ||
|
||
## Table Scan Redirections (TSRs) | ||
|
||
The `rules.json` file configures two tables for TSRs: `postgres.public.customer` | ||
and `postgres.public.orders`. Additional tables can be specified for TSRs by | ||
updating the `rules.json` file. The container logs will display the various | ||
cache service operations as they occur. | ||
|
||
## Materialized Views (MVs) | ||
|
||
An example MV is created in `hive_mv_tsr.mvs.example`. Any number of MVs can be | ||
added to this catalog, and MVs can pull data from any data source. |
67 changes: 67 additions & 0 deletions
67
src/lib/modules/admin/cache-service/resources/bootstrap/bootstrap-trino.sh
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,67 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euxo pipefail | ||
|
||
COUNTER=0 | ||
while [ "${COUNTER}" -lt 30 ] | ||
do | ||
set +e | ||
RESPONSE=$(curl -s -X GET -H 'Accept: application/json' -H 'X-Trino-User: admin' 'trino:8080/v1/info/') | ||
echo "${RESPONSE}" | grep -q '"starting":false' | ||
if [ $? -eq 0 ]; then | ||
echo "Trino health check passed." | ||
sleep 5 | ||
break | ||
fi | ||
COUNTER=$((COUNTER+1)) | ||
sleep 1 | ||
done | ||
|
||
if [ "${COUNTER}" -eq 30 ] | ||
then | ||
echo "Trino health check failed." | ||
exit 1 | ||
fi | ||
|
||
set -e | ||
echo "com.starburstdata.cache=DEBUG" >> /etc/starburst/log.properties | ||
|
||
echo -e "jmx.dump-tables=com.starburstdata.cache.resource:name=cacheresource,\\ | ||
com.starburstdata.cache.resource:name=materializedviewsresource,\\ | ||
com.starburstdata.cache.resource:name=redirectionsresource,\\ | ||
com.starburstdata.cache:name=cleanupservice,\\ | ||
com.starburstdata.cache:name=tableimportservice | ||
jmx.dump-period=10s | ||
jmx.max-entries=86400" >> /etc/starburst/catalog/jmx.properties | ||
|
||
echo "Creating Postgres tables..." | ||
trino-cli --user admin --output-format TSV_HEADER \ | ||
--execute "CREATE TABLE IF NOT EXISTS postgres.public.customer AS SELECT * FROM tpch.tiny.customer" | ||
|
||
trino-cli --user admin --output-format TSV_HEADER \ | ||
--execute "CREATE TABLE IF NOT EXISTS postgres.public.orders AS SELECT * FROM tpch.tiny.orders" | ||
|
||
echo "Creating Hive cache schema (for table scan redirections)..." | ||
trino-cli --user admin --output-format TSV_HEADER \ | ||
--execute "CREATE SCHEMA IF NOT EXISTS hive_mv_tsr.cache WITH (LOCATION = 's3a://sample-bucket/cache/')" | ||
|
||
echo "Creating materialized view schemas..." | ||
trino-cli --user admin --output-format TSV_HEADER \ | ||
--execute "CREATE SCHEMA IF NOT EXISTS hive_mv_tsr.mv_storage WITH (LOCATION = 's3a://sample-bucket/mv/mv_storage/')" | ||
trino-cli --user admin --output-format TSV_HEADER \ | ||
--execute "CREATE SCHEMA IF NOT EXISTS hive_mv_tsr.mvs WITH (LOCATION = 's3a://sample-bucket/mv/mvs/')" | ||
|
||
echo "Creating materialized views..." | ||
QUERY="CREATE OR REPLACE MATERIALIZED VIEW hive_mv_tsr.mvs.example | ||
WITH ( | ||
partitioned_by = ARRAY['orderdate'], | ||
max_import_duration = '1m', | ||
refresh_interval = '5m', | ||
grace_period = '10m' | ||
) | ||
AS | ||
SELECT orderkey, orderdate FROM tpch.tiny.orders | ||
UNION ALL | ||
SELECT orderkey, orderdate FROM tpch.tiny.orders" | ||
|
||
trino-cli --user admin --output-format TSV_HEADER --execute "${QUERY}" |
3 changes: 3 additions & 0 deletions
3
src/lib/modules/admin/cache-service/resources/postgres/cache-svc.env
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,3 @@ | ||
POSTGRES_USER=admin | ||
POSTGRES_PASSWORD=trinoRocks15 | ||
POSTGRES_DB=cachesvc |
6 changes: 6 additions & 0 deletions
6
src/lib/modules/admin/cache-service/resources/trino/cache.properties
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,6 @@ | ||
service-database.user=admin | ||
service-database.password=trinoRocks15 | ||
service-database.jdbc-url=jdbc:postgresql://cache-svc-backend:5432/cachesvc | ||
starburst.user=cachesvc | ||
starburst.jdbc-url=jdbc:trino://trino:8080 | ||
rules.file=/etc/starburst/rules.json |
4 changes: 4 additions & 0 deletions
4
src/lib/modules/admin/cache-service/resources/trino/cache_svc.properties
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,4 @@ | ||
connector.name=postgresql | ||
connection-url=jdbc:postgresql://cache-svc-backend:5432/cachesvc | ||
connection-user=admin | ||
connection-password=trinoRocks15 |
17 changes: 17 additions & 0 deletions
17
src/lib/modules/admin/cache-service/resources/trino/hive_mv_tsr.properties
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,17 @@ | ||
connector.name=hive | ||
hive.metastore.uri=thrift://metastore-hive:9083 | ||
hive.s3.endpoint=http://minio:9000 | ||
hive.s3.aws-access-key=access-key | ||
hive.s3.aws-secret-key=secret-key | ||
hive.non-managed-table-writes-enabled=true | ||
hive.s3.path-style-access=true | ||
|
||
# Cache service specific | ||
hive.security=allow-all | ||
hive.max-partitions-per-writers=1000 | ||
cache-service.uri=http://trino:8180 | ||
|
||
# MVs | ||
materialized-views.enabled=true | ||
materialized-views.namespace=mv_namespace | ||
materialized-views.storage-schema=mv_storage |
25 changes: 25 additions & 0 deletions
25
src/lib/modules/admin/cache-service/resources/trino/rules.json
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,25 @@ | ||
{ | ||
"defaultCacheCatalog": "hive_mv_tsr", | ||
"defaultCacheSchema": "cache", | ||
"defaultMaxImportDuration": "1m", | ||
"rules": [ | ||
{ | ||
"catalogName": "postgres", | ||
"schemaName": "public", | ||
"tableName": "customer", | ||
"refreshInterval": "90s", | ||
"gracePeriod": "5m" | ||
}, | ||
{ | ||
"catalogName": "postgres", | ||
"schemaName": "public", | ||
"tableName": "orders", | ||
"refreshInterval": "90s", | ||
"gracePeriod": "5m", | ||
"columns": [ | ||
"orderkey", | ||
"totalprice" | ||
] | ||
} | ||
] | ||
} |
2 changes: 1 addition & 1 deletion
2
src/lib/modules/admin/file-group-provider/resources/trino/groups.txt
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
sepadmins:admin,admin-1,admin-2 | ||
metadata-users:metadata,metadata-1,metadata-2 | ||
platform-users:platform,platform-1,platform-2 | ||
platform-users:platform,platform-1,platform-2,cachesvc |
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
14 changes: 0 additions & 14 deletions
14
src/lib/modules/catalog/delta-lake/resources/bootstrap/bootstrap-create-buckets.sh
This file was deleted.
Oops, something went wrong.
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
14 changes: 0 additions & 14 deletions
14
src/lib/modules/catalog/hive/resources/bootstrap/bootstrap-create-buckets.sh
This file was deleted.
Oops, something went wrong.
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
14 changes: 0 additions & 14 deletions
14
src/lib/modules/catalog/iceberg/resources/bootstrap/bootstrap-create-buckets.sh
This file was deleted.
Oops, something went wrong.
12 changes: 12 additions & 0 deletions
12
src/lib/modules/security/ldap/resources/ldap/ldap-users/cachesvc.ldif
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,12 @@ | ||
# cachesvc, example.com | ||
dn: uid=cachesvc,dc=example,dc=com | ||
changetype: add | ||
uid: cachesvc | ||
objectClass: inetOrgPerson | ||
objectClass: organizationalPerson | ||
objectClass: person | ||
objectClass: top | ||
cn: cachesvc | ||
sn: cachesvc | ||
mail: cachesvc@example.com | ||
userPassword: trinoRocks15 |
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
Oops, something went wrong.