mirror of
https://github.com/timescale/timescaledb.git
synced 2025-05-18 11:45:11 +08:00
Don't try to compress osm chunks
This patch filters out the osm chunk in the compression policy and adds some additional checks so we dont run compress_chunk on osm chunks.
This commit is contained in:
parent
7d6332e83a
commit
23b2665d42
@ -95,7 +95,7 @@ BEGIN
|
|||||||
INNER JOIN pg_namespace pgns ON pgc.relnamespace = pgns.oid
|
INNER JOIN pg_namespace pgns ON pgc.relnamespace = pgns.oid
|
||||||
INNER JOIN _timescaledb_catalog.chunk ch ON ch.table_name = pgc.relname AND ch.schema_name = pgns.nspname AND ch.hypertable_id = htid
|
INNER JOIN _timescaledb_catalog.chunk ch ON ch.table_name = pgc.relname AND ch.schema_name = pgns.nspname AND ch.hypertable_id = htid
|
||||||
WHERE
|
WHERE
|
||||||
ch.dropped IS FALSE
|
NOT ch.dropped AND NOT ch.osm_chunk
|
||||||
AND (
|
AND (
|
||||||
ch.status = 0 OR
|
ch.status = 0 OR
|
||||||
(
|
(
|
||||||
|
22
src/chunk.c
22
src/chunk.c
@ -4383,6 +4383,28 @@ ts_chunk_validate_chunk_status_for_operation(const Chunk *chunk, ChunkOperation
|
|||||||
Oid chunk_relid = chunk->table_id;
|
Oid chunk_relid = chunk->table_id;
|
||||||
int32 chunk_status = chunk->fd.status;
|
int32 chunk_status = chunk->fd.status;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Block everything but DELETE on OSM chunks.
|
||||||
|
*/
|
||||||
|
if (chunk->fd.osm_chunk)
|
||||||
|
{
|
||||||
|
switch (cmd)
|
||||||
|
{
|
||||||
|
case CHUNK_DROP:
|
||||||
|
return true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
if (throw_error)
|
||||||
|
elog(ERROR,
|
||||||
|
"%s not permitted on tiered chunk \"%s\" ",
|
||||||
|
get_chunk_operation_str(cmd),
|
||||||
|
get_rel_name(chunk_relid));
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Handle frozen chunks */
|
/* Handle frozen chunks */
|
||||||
if (ts_flags_are_set_32(chunk_status, CHUNK_STATUS_FROZEN))
|
if (ts_flags_are_set_32(chunk_status, CHUNK_STATUS_FROZEN))
|
||||||
{
|
{
|
||||||
|
@ -58,7 +58,7 @@ chunk_freeze_chunk(PG_FUNCTION_ARGS)
|
|||||||
{
|
{
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||||
errmsg("operation not supported on distributed chunk or foreign table \"%s\"",
|
errmsg("operation not supported on tiered chunk \"%s\"",
|
||||||
get_rel_name(chunk_relid))));
|
get_rel_name(chunk_relid))));
|
||||||
}
|
}
|
||||||
if (ts_chunk_is_frozen(chunk))
|
if (ts_chunk_is_frozen(chunk))
|
||||||
|
@ -281,6 +281,10 @@ compress_chunk(Oid in_table, Oid out_table, int insert_options)
|
|||||||
*/
|
*/
|
||||||
Relation out_rel = relation_open(out_table, ExclusiveLock);
|
Relation out_rel = relation_open(out_table, ExclusiveLock);
|
||||||
|
|
||||||
|
/* Sanity check we are dealing with relations */
|
||||||
|
Ensure(in_rel->rd_rel->relkind == RELKIND_RELATION, "compress_chunk called on non-relation");
|
||||||
|
Ensure(out_rel->rd_rel->relkind == RELKIND_RELATION, "compress_chunk called on non-relation");
|
||||||
|
|
||||||
TupleDesc in_desc = RelationGetDescr(in_rel);
|
TupleDesc in_desc = RelationGetDescr(in_rel);
|
||||||
TupleDesc out_desc = RelationGetDescr(out_rel);
|
TupleDesc out_desc = RelationGetDescr(out_rel);
|
||||||
/* Before calling row compressor relation should be segmented and sorted as configured
|
/* Before calling row compressor relation should be segmented and sorted as configured
|
||||||
|
@ -810,3 +810,16 @@ ALTER TABLE table_unique_index SET (timescaledb.compress, timescaledb.compress_s
|
|||||||
ALTER TABLE table_unique_index SET (timescaledb.compress = off);
|
ALTER TABLE table_unique_index SET (timescaledb.compress = off);
|
||||||
ALTER TABLE table_unique_index SET (timescaledb.compress, timescaledb.compress_segmentby = 'time,location,device_id');
|
ALTER TABLE table_unique_index SET (timescaledb.compress, timescaledb.compress_segmentby = 'time,location,device_id');
|
||||||
ALTER TABLE table_unique_index SET (timescaledb.compress = off);
|
ALTER TABLE table_unique_index SET (timescaledb.compress = off);
|
||||||
|
-- try compressing osm chunk
|
||||||
|
CREATE TABLE osm_table (time timestamptz NOT NULL, device_id text, value float);
|
||||||
|
SELECT table_name FROM create_hypertable('osm_table', 'time');
|
||||||
|
table_name
|
||||||
|
------------
|
||||||
|
osm_table
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
ALTER TABLE osm_table SET (timescaledb.compress);
|
||||||
|
INSERT INTO osm_table VALUES ('2022-11-11 11:11:11', 'foo', 1.0);
|
||||||
|
UPDATE _timescaledb_catalog.chunk ch SET osm_chunk = true FROM _timescaledb_catalog.hypertable ht WHERE ch.hypertable_id = ht.id AND ht.table_name='osm_table';
|
||||||
|
SELECT compress_chunk(show_chunks('osm_table'));
|
||||||
|
ERROR: compress_chunk not permitted on tiered chunk "_hyper_43_31_chunk"
|
||||||
|
@ -810,3 +810,16 @@ ALTER TABLE table_unique_index SET (timescaledb.compress, timescaledb.compress_s
|
|||||||
ALTER TABLE table_unique_index SET (timescaledb.compress = off);
|
ALTER TABLE table_unique_index SET (timescaledb.compress = off);
|
||||||
ALTER TABLE table_unique_index SET (timescaledb.compress, timescaledb.compress_segmentby = 'time,location,device_id');
|
ALTER TABLE table_unique_index SET (timescaledb.compress, timescaledb.compress_segmentby = 'time,location,device_id');
|
||||||
ALTER TABLE table_unique_index SET (timescaledb.compress = off);
|
ALTER TABLE table_unique_index SET (timescaledb.compress = off);
|
||||||
|
-- try compressing osm chunk
|
||||||
|
CREATE TABLE osm_table (time timestamptz NOT NULL, device_id text, value float);
|
||||||
|
SELECT table_name FROM create_hypertable('osm_table', 'time');
|
||||||
|
table_name
|
||||||
|
------------
|
||||||
|
osm_table
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
ALTER TABLE osm_table SET (timescaledb.compress);
|
||||||
|
INSERT INTO osm_table VALUES ('2022-11-11 11:11:11', 'foo', 1.0);
|
||||||
|
UPDATE _timescaledb_catalog.chunk ch SET osm_chunk = true FROM _timescaledb_catalog.hypertable ht WHERE ch.hypertable_id = ht.id AND ht.table_name='osm_table';
|
||||||
|
SELECT compress_chunk(show_chunks('osm_table'));
|
||||||
|
ERROR: compress_chunk not permitted on tiered chunk "_hyper_43_31_chunk"
|
||||||
|
@ -810,3 +810,16 @@ ALTER TABLE table_unique_index SET (timescaledb.compress, timescaledb.compress_s
|
|||||||
ALTER TABLE table_unique_index SET (timescaledb.compress = off);
|
ALTER TABLE table_unique_index SET (timescaledb.compress = off);
|
||||||
ALTER TABLE table_unique_index SET (timescaledb.compress, timescaledb.compress_segmentby = 'time,location,device_id');
|
ALTER TABLE table_unique_index SET (timescaledb.compress, timescaledb.compress_segmentby = 'time,location,device_id');
|
||||||
ALTER TABLE table_unique_index SET (timescaledb.compress = off);
|
ALTER TABLE table_unique_index SET (timescaledb.compress = off);
|
||||||
|
-- try compressing osm chunk
|
||||||
|
CREATE TABLE osm_table (time timestamptz NOT NULL, device_id text, value float);
|
||||||
|
SELECT table_name FROM create_hypertable('osm_table', 'time');
|
||||||
|
table_name
|
||||||
|
------------
|
||||||
|
osm_table
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
ALTER TABLE osm_table SET (timescaledb.compress);
|
||||||
|
INSERT INTO osm_table VALUES ('2022-11-11 11:11:11', 'foo', 1.0);
|
||||||
|
UPDATE _timescaledb_catalog.chunk ch SET osm_chunk = true FROM _timescaledb_catalog.hypertable ht WHERE ch.hypertable_id = ht.id AND ht.table_name='osm_table';
|
||||||
|
SELECT compress_chunk(show_chunks('osm_table'));
|
||||||
|
ERROR: compress_chunk not permitted on tiered chunk "_hyper_43_31_chunk"
|
||||||
|
@ -810,3 +810,16 @@ ALTER TABLE table_unique_index SET (timescaledb.compress, timescaledb.compress_s
|
|||||||
ALTER TABLE table_unique_index SET (timescaledb.compress = off);
|
ALTER TABLE table_unique_index SET (timescaledb.compress = off);
|
||||||
ALTER TABLE table_unique_index SET (timescaledb.compress, timescaledb.compress_segmentby = 'time,location,device_id');
|
ALTER TABLE table_unique_index SET (timescaledb.compress, timescaledb.compress_segmentby = 'time,location,device_id');
|
||||||
ALTER TABLE table_unique_index SET (timescaledb.compress = off);
|
ALTER TABLE table_unique_index SET (timescaledb.compress = off);
|
||||||
|
-- try compressing osm chunk
|
||||||
|
CREATE TABLE osm_table (time timestamptz NOT NULL, device_id text, value float);
|
||||||
|
SELECT table_name FROM create_hypertable('osm_table', 'time');
|
||||||
|
table_name
|
||||||
|
------------
|
||||||
|
osm_table
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
ALTER TABLE osm_table SET (timescaledb.compress);
|
||||||
|
INSERT INTO osm_table VALUES ('2022-11-11 11:11:11', 'foo', 1.0);
|
||||||
|
UPDATE _timescaledb_catalog.chunk ch SET osm_chunk = true FROM _timescaledb_catalog.hypertable ht WHERE ch.hypertable_id = ht.id AND ht.table_name='osm_table';
|
||||||
|
SELECT compress_chunk(show_chunks('osm_table'));
|
||||||
|
ERROR: compress_chunk not permitted on tiered chunk "_hyper_43_31_chunk"
|
||||||
|
@ -500,3 +500,14 @@ ALTER TABLE table_unique_index SET (timescaledb.compress = off);
|
|||||||
ALTER TABLE table_unique_index SET (timescaledb.compress, timescaledb.compress_segmentby = 'time,location,device_id');
|
ALTER TABLE table_unique_index SET (timescaledb.compress, timescaledb.compress_segmentby = 'time,location,device_id');
|
||||||
ALTER TABLE table_unique_index SET (timescaledb.compress = off);
|
ALTER TABLE table_unique_index SET (timescaledb.compress = off);
|
||||||
|
|
||||||
|
-- try compressing osm chunk
|
||||||
|
CREATE TABLE osm_table (time timestamptz NOT NULL, device_id text, value float);
|
||||||
|
SELECT table_name FROM create_hypertable('osm_table', 'time');
|
||||||
|
ALTER TABLE osm_table SET (timescaledb.compress);
|
||||||
|
|
||||||
|
INSERT INTO osm_table VALUES ('2022-11-11 11:11:11', 'foo', 1.0);
|
||||||
|
|
||||||
|
UPDATE _timescaledb_catalog.chunk ch SET osm_chunk = true FROM _timescaledb_catalog.hypertable ht WHERE ch.hypertable_id = ht.id AND ht.table_name='osm_table';
|
||||||
|
|
||||||
|
SELECT compress_chunk(show_chunks('osm_table'));
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user