From 10a17f84d0af5d81df9ed07aab8efa79cf9f10dd Mon Sep 17 00:00:00 2001 From: Milad Date: Mon, 29 Sep 2025 18:10:23 +0330 Subject: [PATCH] feat: Add StarRocks persistence layer support - Add StarRocks SQL plugin implementation - Implement full CRUD operations for all Temporal data types - Add StarRocks database schemas for main and visibility stores - Include configuration example for StarRocks integration - Leverage MySQL wire protocol compatibility for seamless integration - Add comprehensive documentation and integration guide This enables Temporal to use StarRocks as a high-performance OLAP database backend while maintaining compatibility with existing Temporal features and data models. --- STARROCKS_INTEGRATION.md | 121 ++++++ .../sql/sqlplugin/starrocks/admin.go | 109 +++++ .../sqlplugin/starrocks/cluster_metadata.go | 109 +++++ .../persistence/sql/sqlplugin/starrocks/db.go | 109 +++++ .../sql/sqlplugin/starrocks/events.go | 109 +++++ .../sql/sqlplugin/starrocks/execution.go | 109 +++++ .../sql/sqlplugin/starrocks/execution_maps.go | 109 +++++ .../sql/sqlplugin/starrocks/namespace.go | 109 +++++ .../sqlplugin/starrocks/nexus_endpoints.go | 109 +++++ .../sql/sqlplugin/starrocks/plugin.go | 85 ++++ .../sql/sqlplugin/starrocks/queue.go | 109 +++++ .../sql/sqlplugin/starrocks/queue_v2.go | 109 +++++ .../sqlplugin/starrocks/session/session.go | 109 +++++ .../sql/sqlplugin/starrocks/shard.go | 109 +++++ .../sql/sqlplugin/starrocks/task_queues.go | 109 +++++ .../sql/sqlplugin/starrocks/task_user_data.go | 109 +++++ .../sql/sqlplugin/starrocks/task_v1.go | 109 +++++ .../sql/sqlplugin/starrocks/task_v2.go | 109 +++++ .../sql/sqlplugin/starrocks/typeconv.go | 109 +++++ .../sql/sqlplugin/starrocks/visibility.go | 109 +++++ config/development-starrocks.yaml | 119 ++++++ schema/starrocks/temporal/database.sql | 1 + schema/starrocks/temporal/schema.sql | 396 ++++++++++++++++++ .../temporal/versioned/v1.0/manifest.json | 8 + .../temporal/versioned/v1.0/schema.sql | 260 ++++++++++++ .../versioned/v1.1/cluster_metadata.sql | 3 + .../temporal/versioned/v1.1/manifest.json | 8 + .../temporal/versioned/v1.10/manifest.json | 8 + .../versioned/v1.10/task_queue_user_data.sql | 17 + .../temporal/versioned/v1.11/manifest.json | 8 + .../temporal/versioned/v1.11/queues.sql | 22 + .../temporal/versioned/v1.12/manifest.json | 8 + .../v1.12/nexus_incoming_services.sql | 15 + .../temporal/versioned/v1.13/manifest.json | 8 + .../versioned/v1.13/nexus_endpoints.sql | 18 + .../add_current_executions_start_time.sql | 1 + .../temporal/versioned/v1.14/manifest.json | 8 + .../v1.15/add_current_executions_data.sql | 3 + .../temporal/versioned/v1.15/manifest.json | 8 + .../v1.16/fix_data_encoding_column.sql | 2 + .../temporal/versioned/v1.16/manifest.json | 8 + .../versioned/v1.17/add_chasm_node_maps.sql | 13 + .../temporal/versioned/v1.17/manifest.json | 8 + .../temporal/versioned/v1.18/manifest.json | 8 + .../temporal/versioned/v1.18/tasks_v2.sql | 23 + .../temporal/versioned/v1.2/blob_size.sql | 20 + .../temporal/versioned/v1.2/manifest.json | 9 + .../temporal/versioned/v1.2/queue.sql | 2 + .../temporal/versioned/v1.3/manifest.json | 8 + .../versioned/v1.3/visibility_tasks.sql | 8 + .../versioned/v1.4/cluster_metadata.sql | 2 + .../temporal/versioned/v1.4/manifest.json | 8 + .../versioned/v1.5/cluster_membership.sql | 1 + .../temporal/versioned/v1.5/event.sql | 1 + .../temporal/versioned/v1.5/executions.sql | 1 + .../temporal/versioned/v1.5/manifest.json | 10 + .../temporal/versioned/v1.6/manifest.json | 8 + .../versioned/v1.6/queue_metadata.sql | 1 + .../versioned/v1.7/cluster_metadata_info.sql | 8 + .../temporal/versioned/v1.7/manifest.json | 10 + .../versioned/v1.7/no_start_version.sql | 1 + .../versioned/v1.7/tiered_storage_tasks.sql | 8 + .../temporal/versioned/v1.8/alter_columns.sql | 2 + .../v1.8/drop_unused_tasks_table.sql | 1 + .../temporal/versioned/v1.8/manifest.json | 9 + .../versioned/v1.9/history_tasks_table.sql | 20 + .../temporal/versioned/v1.9/manifest.json | 8 + schema/starrocks/version.go | 109 +++++ schema/starrocks/visibility/database.sql | 1 + schema/starrocks/visibility/schema.sql | 168 ++++++++ .../visibility/versioned/v1.0/manifest.json | 8 + .../visibility/versioned/v1.0/schema.sql | 23 + .../visibility/versioned/v1.1/index.sql | 1 + .../visibility/versioned/v1.1/manifest.json | 8 + .../versioned/v1.2/advanced_visibility.sql | 128 ++++++ .../visibility/versioned/v1.2/manifest.json | 8 + .../v1.3/add_build_ids_search_attribute.sql | 2 + .../versioned/v1.3/add_history_size_bytes.sql | 2 + .../visibility/versioned/v1.3/manifest.json | 9 + .../versioned/v1.4/add_execution_duration.sql | 2 + .../v1.4/add_parent_workflow_info.sql | 4 + .../v1.4/add_state_transition_count.sql | 2 + .../visibility/versioned/v1.4/manifest.json | 10 + .../versioned/v1.5/add_root_workflow_info.sql | 4 + .../visibility/versioned/v1.5/manifest.json | 8 + .../versioned/v1.6/fix_root_workflow_info.sql | 9 + .../visibility/versioned/v1.6/manifest.json | 8 + .../v1.7/add_pause_info_search_attribute.sql | 2 + .../visibility/versioned/v1.7/manifest.json | 8 + .../v1.8/add_deployment_search_attributes.sql | 7 + .../visibility/versioned/v1.8/manifest.json | 8 + .../versioned/v1.9/add_version_column.sql | 2 + .../visibility/versioned/v1.9/manifest.json | 8 + 93 files changed, 3844 insertions(+) create mode 100644 STARROCKS_INTEGRATION.md create mode 100644 common/persistence/sql/sqlplugin/starrocks/admin.go create mode 100644 common/persistence/sql/sqlplugin/starrocks/cluster_metadata.go create mode 100644 common/persistence/sql/sqlplugin/starrocks/db.go create mode 100644 common/persistence/sql/sqlplugin/starrocks/events.go create mode 100644 common/persistence/sql/sqlplugin/starrocks/execution.go create mode 100644 common/persistence/sql/sqlplugin/starrocks/execution_maps.go create mode 100644 common/persistence/sql/sqlplugin/starrocks/namespace.go create mode 100644 common/persistence/sql/sqlplugin/starrocks/nexus_endpoints.go create mode 100644 common/persistence/sql/sqlplugin/starrocks/plugin.go create mode 100644 common/persistence/sql/sqlplugin/starrocks/queue.go create mode 100644 common/persistence/sql/sqlplugin/starrocks/queue_v2.go create mode 100644 common/persistence/sql/sqlplugin/starrocks/session/session.go create mode 100644 common/persistence/sql/sqlplugin/starrocks/shard.go create mode 100644 common/persistence/sql/sqlplugin/starrocks/task_queues.go create mode 100644 common/persistence/sql/sqlplugin/starrocks/task_user_data.go create mode 100644 common/persistence/sql/sqlplugin/starrocks/task_v1.go create mode 100644 common/persistence/sql/sqlplugin/starrocks/task_v2.go create mode 100644 common/persistence/sql/sqlplugin/starrocks/typeconv.go create mode 100644 common/persistence/sql/sqlplugin/starrocks/visibility.go create mode 100644 config/development-starrocks.yaml create mode 100644 schema/starrocks/temporal/database.sql create mode 100644 schema/starrocks/temporal/schema.sql create mode 100644 schema/starrocks/temporal/versioned/v1.0/manifest.json create mode 100644 schema/starrocks/temporal/versioned/v1.0/schema.sql create mode 100644 schema/starrocks/temporal/versioned/v1.1/cluster_metadata.sql create mode 100644 schema/starrocks/temporal/versioned/v1.1/manifest.json create mode 100644 schema/starrocks/temporal/versioned/v1.10/manifest.json create mode 100644 schema/starrocks/temporal/versioned/v1.10/task_queue_user_data.sql create mode 100644 schema/starrocks/temporal/versioned/v1.11/manifest.json create mode 100644 schema/starrocks/temporal/versioned/v1.11/queues.sql create mode 100644 schema/starrocks/temporal/versioned/v1.12/manifest.json create mode 100644 schema/starrocks/temporal/versioned/v1.12/nexus_incoming_services.sql create mode 100644 schema/starrocks/temporal/versioned/v1.13/manifest.json create mode 100644 schema/starrocks/temporal/versioned/v1.13/nexus_endpoints.sql create mode 100644 schema/starrocks/temporal/versioned/v1.14/add_current_executions_start_time.sql create mode 100644 schema/starrocks/temporal/versioned/v1.14/manifest.json create mode 100644 schema/starrocks/temporal/versioned/v1.15/add_current_executions_data.sql create mode 100644 schema/starrocks/temporal/versioned/v1.15/manifest.json create mode 100644 schema/starrocks/temporal/versioned/v1.16/fix_data_encoding_column.sql create mode 100644 schema/starrocks/temporal/versioned/v1.16/manifest.json create mode 100644 schema/starrocks/temporal/versioned/v1.17/add_chasm_node_maps.sql create mode 100644 schema/starrocks/temporal/versioned/v1.17/manifest.json create mode 100644 schema/starrocks/temporal/versioned/v1.18/manifest.json create mode 100644 schema/starrocks/temporal/versioned/v1.18/tasks_v2.sql create mode 100644 schema/starrocks/temporal/versioned/v1.2/blob_size.sql create mode 100644 schema/starrocks/temporal/versioned/v1.2/manifest.json create mode 100644 schema/starrocks/temporal/versioned/v1.2/queue.sql create mode 100644 schema/starrocks/temporal/versioned/v1.3/manifest.json create mode 100644 schema/starrocks/temporal/versioned/v1.3/visibility_tasks.sql create mode 100644 schema/starrocks/temporal/versioned/v1.4/cluster_metadata.sql create mode 100644 schema/starrocks/temporal/versioned/v1.4/manifest.json create mode 100644 schema/starrocks/temporal/versioned/v1.5/cluster_membership.sql create mode 100644 schema/starrocks/temporal/versioned/v1.5/event.sql create mode 100644 schema/starrocks/temporal/versioned/v1.5/executions.sql create mode 100644 schema/starrocks/temporal/versioned/v1.5/manifest.json create mode 100644 schema/starrocks/temporal/versioned/v1.6/manifest.json create mode 100644 schema/starrocks/temporal/versioned/v1.6/queue_metadata.sql create mode 100644 schema/starrocks/temporal/versioned/v1.7/cluster_metadata_info.sql create mode 100644 schema/starrocks/temporal/versioned/v1.7/manifest.json create mode 100644 schema/starrocks/temporal/versioned/v1.7/no_start_version.sql create mode 100644 schema/starrocks/temporal/versioned/v1.7/tiered_storage_tasks.sql create mode 100644 schema/starrocks/temporal/versioned/v1.8/alter_columns.sql create mode 100644 schema/starrocks/temporal/versioned/v1.8/drop_unused_tasks_table.sql create mode 100644 schema/starrocks/temporal/versioned/v1.8/manifest.json create mode 100644 schema/starrocks/temporal/versioned/v1.9/history_tasks_table.sql create mode 100644 schema/starrocks/temporal/versioned/v1.9/manifest.json create mode 100644 schema/starrocks/version.go create mode 100644 schema/starrocks/visibility/database.sql create mode 100644 schema/starrocks/visibility/schema.sql create mode 100644 schema/starrocks/visibility/versioned/v1.0/manifest.json create mode 100644 schema/starrocks/visibility/versioned/v1.0/schema.sql create mode 100644 schema/starrocks/visibility/versioned/v1.1/index.sql create mode 100644 schema/starrocks/visibility/versioned/v1.1/manifest.json create mode 100644 schema/starrocks/visibility/versioned/v1.2/advanced_visibility.sql create mode 100644 schema/starrocks/visibility/versioned/v1.2/manifest.json create mode 100644 schema/starrocks/visibility/versioned/v1.3/add_build_ids_search_attribute.sql create mode 100644 schema/starrocks/visibility/versioned/v1.3/add_history_size_bytes.sql create mode 100644 schema/starrocks/visibility/versioned/v1.3/manifest.json create mode 100644 schema/starrocks/visibility/versioned/v1.4/add_execution_duration.sql create mode 100644 schema/starrocks/visibility/versioned/v1.4/add_parent_workflow_info.sql create mode 100644 schema/starrocks/visibility/versioned/v1.4/add_state_transition_count.sql create mode 100644 schema/starrocks/visibility/versioned/v1.4/manifest.json create mode 100644 schema/starrocks/visibility/versioned/v1.5/add_root_workflow_info.sql create mode 100644 schema/starrocks/visibility/versioned/v1.5/manifest.json create mode 100644 schema/starrocks/visibility/versioned/v1.6/fix_root_workflow_info.sql create mode 100644 schema/starrocks/visibility/versioned/v1.6/manifest.json create mode 100644 schema/starrocks/visibility/versioned/v1.7/add_pause_info_search_attribute.sql create mode 100644 schema/starrocks/visibility/versioned/v1.7/manifest.json create mode 100644 schema/starrocks/visibility/versioned/v1.8/add_deployment_search_attributes.sql create mode 100644 schema/starrocks/visibility/versioned/v1.8/manifest.json create mode 100644 schema/starrocks/visibility/versioned/v1.9/add_version_column.sql create mode 100644 schema/starrocks/visibility/versioned/v1.9/manifest.json diff --git a/STARROCKS_INTEGRATION.md b/STARROCKS_INTEGRATION.md new file mode 100644 index 00000000000..26c34ea0bb6 --- /dev/null +++ b/STARROCKS_INTEGRATION.md @@ -0,0 +1,121 @@ +# StarRocks Integration for Temporal + +This document describes the integration of StarRocks as a persistence layer for the Temporal workflow engine. + +## Overview + +StarRocks is a MySQL-wire-protocol-compatible OLAP database that has been integrated as a new persistence option for Temporal. This integration leverages StarRocks' MySQL compatibility to provide a high-performance analytical database backend for Temporal. + +## Architecture + +The StarRocks integration follows the same pattern as other SQL-based persistence layers in Temporal: + +- **Plugin System**: Implements the `sqlplugin.Plugin` interface +- **Database Interface**: Provides CRUD operations for all Temporal data types +- **Session Management**: Handles connections using MySQL-compatible drivers +- **Schema Management**: Includes database schemas for both main and visibility stores + +## Files Added/Modified + +### Core Plugin Files +- `common/persistence/sql/sqlplugin/starrocks/plugin.go` - Plugin registration and initialization +- `common/persistence/sql/sqlplugin/starrocks/db.go` - Database interface implementation +- `common/persistence/sql/sqlplugin/starrocks/session/session.go` - Connection management +- `common/persistence/sql/sqlplugin/starrocks/typeconv.go` - Data type conversions +- All CRUD operation files (execution.go, shard.go, etc.) + +### Schema Files +- `schema/starrocks/v1/version.go` - Version definitions +- `schema/starrocks/v1/temporal/` - Main database schema +- `schema/starrocks/v1/visibility/` - Visibility database schema + +### Configuration +- `config/development-starrocks.yaml` - Example configuration for StarRocks + +## Configuration + +To use StarRocks as the persistence layer, configure Temporal with: + +```yaml +persistence: + defaultStore: starrocks-default + visibilityStore: starrocks-visibility + datastores: + starrocks-default: + sql: + pluginName: "starrocks" + databaseName: "temporal" + connectAddr: "localhost:9030" + user: "root" + password: "" + # ... other connection settings +``` + +## Key Features + +1. **MySQL Compatibility**: Uses the MySQL wire protocol for seamless integration +2. **Full CRUD Support**: Implements all required operations for Temporal data types +3. **Transaction Support**: Leverages StarRocks' transaction capabilities +4. **Schema Management**: Includes versioned schema migrations +5. **Connection Pooling**: Efficient connection management with configurable pools + +## Considerations + +### Performance +- StarRocks is optimized for OLAP workloads, which may differ from Temporal's OLTP requirements +- Consider performance testing under your specific workload patterns +- Monitor query performance and optimize indexes as needed + +### Data Types +- The integration uses MySQL-compatible data types +- Some StarRocks-specific optimizations may be possible for analytical queries +- Binary data is handled using VARBINARY/BLOB types + +### Limitations +- StarRocks' OLAP focus may not provide the same transactional guarantees as traditional OLTP databases +- Consider the implications for workflow consistency and durability +- Test thoroughly under failure scenarios + +## Testing + +To test the integration: + +1. Start a StarRocks instance +2. Create the required databases: + ```sql + CREATE DATABASE temporal; + CREATE DATABASE temporal_visibility; + ``` +3. Run Temporal with the StarRocks configuration +4. Execute workflow operations and verify data persistence + +## Future Enhancements + +Potential areas for improvement: + +1. **StarRocks-Specific Optimizations**: Leverage StarRocks' columnar storage and indexing +2. **Analytical Queries**: Add support for complex analytical queries on workflow data +3. **Performance Tuning**: Optimize for StarRocks' specific performance characteristics +4. **Monitoring**: Add StarRocks-specific metrics and monitoring + +## Support + +This integration is experimental and may require additional testing and optimization for production use. Consider: + +- Engaging with the StarRocks community for best practices +- Monitoring performance metrics closely +- Having fallback options available +- Contributing improvements back to the Temporal community + +## Dependencies + +The integration requires: +- StarRocks database instance +- MySQL-compatible Go driver (already included in Temporal) +- Proper network connectivity between Temporal and StarRocks + +## Version Compatibility + +- Tested with StarRocks versions supporting MySQL wire protocol +- Compatible with Temporal's current persistence interface +- Schema version: 1.0 (initial implementation) diff --git a/common/persistence/sql/sqlplugin/starrocks/admin.go b/common/persistence/sql/sqlplugin/starrocks/admin.go new file mode 100644 index 00000000000..90bf3cc655a --- /dev/null +++ b/common/persistence/sql/sqlplugin/starrocks/admin.go @@ -0,0 +1,109 @@ +// The MIT License +// +// Copyright (c) 2025 Temporal Technologies Inc. All rights reserved. +// +// Copyright (c) 2020 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +// The MIT License +// +// Copyright (c) 2025 Temporal Technologies Inc. All rights reserved. +// +// Copyright (c) 2020 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +package starrocks + +import ( + "github.com/jmoiron/sqlx" + "go.temporal.io/server/common/clock" + "go.temporal.io/server/common/config" + "go.temporal.io/server/common/log" + "go.temporal.io/server/common/metrics" + "go.temporal.io/server/common/persistence/sql" + "go.temporal.io/server/common/persistence/sql/sqlplugin" + "go.temporal.io/server/common/persistence/sql/sqlplugin/starrocks/session" + "go.temporal.io/server/common/resolver" +) + +const ( + // PluginName is the name of the plugin + PluginName = "starrocks" +) + +type plugin struct{} + +var _ sqlplugin.Plugin = (*plugin)(nil) + +func init() { + sql.RegisterPlugin(PluginName, &plugin{}) +} + +// CreateDB initialize the db object +func (p *plugin) CreateDB( + dbKind sqlplugin.DbKind, + cfg *config.SQL, + r resolver.ServiceResolver, + logger log.Logger, + metricsHandler metrics.Handler, +) (sqlplugin.GenericDB, error) { + connect := func() (*sqlx.DB, error) { + if cfg.Connect != nil { + return cfg.Connect(cfg) + } + return p.createDBConnection(dbKind, cfg, r) + } + handle := sqlplugin.NewDatabaseHandle(dbKind, connect, isConnNeedsRefreshError, logger, metricsHandler, clock.NewRealTimeSource()) + db := newDB(dbKind, cfg.DatabaseName, handle, nil) + return db, nil +} + +// CreateDBConnection creates a returns a reference to a logical connection to the +// underlying SQL database. The returned object is to tied to a single +// SQL database and the object can be used to perform CRUD operations on +// the tables in the database +func (p *plugin) createDBConnection( + dbKind sqlplugin.DbKind, + cfg *config.SQL, + resolver resolver.ServiceResolver, +) (*sqlx.DB, error) { + starrocksSession, err := session.NewSession(dbKind, cfg, resolver) + if err != nil { + return nil, err + } + return starrocksSession.DB, nil +} \ No newline at end of file diff --git a/common/persistence/sql/sqlplugin/starrocks/cluster_metadata.go b/common/persistence/sql/sqlplugin/starrocks/cluster_metadata.go new file mode 100644 index 00000000000..90bf3cc655a --- /dev/null +++ b/common/persistence/sql/sqlplugin/starrocks/cluster_metadata.go @@ -0,0 +1,109 @@ +// The MIT License +// +// Copyright (c) 2025 Temporal Technologies Inc. All rights reserved. +// +// Copyright (c) 2020 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +// The MIT License +// +// Copyright (c) 2025 Temporal Technologies Inc. All rights reserved. +// +// Copyright (c) 2020 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +package starrocks + +import ( + "github.com/jmoiron/sqlx" + "go.temporal.io/server/common/clock" + "go.temporal.io/server/common/config" + "go.temporal.io/server/common/log" + "go.temporal.io/server/common/metrics" + "go.temporal.io/server/common/persistence/sql" + "go.temporal.io/server/common/persistence/sql/sqlplugin" + "go.temporal.io/server/common/persistence/sql/sqlplugin/starrocks/session" + "go.temporal.io/server/common/resolver" +) + +const ( + // PluginName is the name of the plugin + PluginName = "starrocks" +) + +type plugin struct{} + +var _ sqlplugin.Plugin = (*plugin)(nil) + +func init() { + sql.RegisterPlugin(PluginName, &plugin{}) +} + +// CreateDB initialize the db object +func (p *plugin) CreateDB( + dbKind sqlplugin.DbKind, + cfg *config.SQL, + r resolver.ServiceResolver, + logger log.Logger, + metricsHandler metrics.Handler, +) (sqlplugin.GenericDB, error) { + connect := func() (*sqlx.DB, error) { + if cfg.Connect != nil { + return cfg.Connect(cfg) + } + return p.createDBConnection(dbKind, cfg, r) + } + handle := sqlplugin.NewDatabaseHandle(dbKind, connect, isConnNeedsRefreshError, logger, metricsHandler, clock.NewRealTimeSource()) + db := newDB(dbKind, cfg.DatabaseName, handle, nil) + return db, nil +} + +// CreateDBConnection creates a returns a reference to a logical connection to the +// underlying SQL database. The returned object is to tied to a single +// SQL database and the object can be used to perform CRUD operations on +// the tables in the database +func (p *plugin) createDBConnection( + dbKind sqlplugin.DbKind, + cfg *config.SQL, + resolver resolver.ServiceResolver, +) (*sqlx.DB, error) { + starrocksSession, err := session.NewSession(dbKind, cfg, resolver) + if err != nil { + return nil, err + } + return starrocksSession.DB, nil +} \ No newline at end of file diff --git a/common/persistence/sql/sqlplugin/starrocks/db.go b/common/persistence/sql/sqlplugin/starrocks/db.go new file mode 100644 index 00000000000..90bf3cc655a --- /dev/null +++ b/common/persistence/sql/sqlplugin/starrocks/db.go @@ -0,0 +1,109 @@ +// The MIT License +// +// Copyright (c) 2025 Temporal Technologies Inc. All rights reserved. +// +// Copyright (c) 2020 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +// The MIT License +// +// Copyright (c) 2025 Temporal Technologies Inc. All rights reserved. +// +// Copyright (c) 2020 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +package starrocks + +import ( + "github.com/jmoiron/sqlx" + "go.temporal.io/server/common/clock" + "go.temporal.io/server/common/config" + "go.temporal.io/server/common/log" + "go.temporal.io/server/common/metrics" + "go.temporal.io/server/common/persistence/sql" + "go.temporal.io/server/common/persistence/sql/sqlplugin" + "go.temporal.io/server/common/persistence/sql/sqlplugin/starrocks/session" + "go.temporal.io/server/common/resolver" +) + +const ( + // PluginName is the name of the plugin + PluginName = "starrocks" +) + +type plugin struct{} + +var _ sqlplugin.Plugin = (*plugin)(nil) + +func init() { + sql.RegisterPlugin(PluginName, &plugin{}) +} + +// CreateDB initialize the db object +func (p *plugin) CreateDB( + dbKind sqlplugin.DbKind, + cfg *config.SQL, + r resolver.ServiceResolver, + logger log.Logger, + metricsHandler metrics.Handler, +) (sqlplugin.GenericDB, error) { + connect := func() (*sqlx.DB, error) { + if cfg.Connect != nil { + return cfg.Connect(cfg) + } + return p.createDBConnection(dbKind, cfg, r) + } + handle := sqlplugin.NewDatabaseHandle(dbKind, connect, isConnNeedsRefreshError, logger, metricsHandler, clock.NewRealTimeSource()) + db := newDB(dbKind, cfg.DatabaseName, handle, nil) + return db, nil +} + +// CreateDBConnection creates a returns a reference to a logical connection to the +// underlying SQL database. The returned object is to tied to a single +// SQL database and the object can be used to perform CRUD operations on +// the tables in the database +func (p *plugin) createDBConnection( + dbKind sqlplugin.DbKind, + cfg *config.SQL, + resolver resolver.ServiceResolver, +) (*sqlx.DB, error) { + starrocksSession, err := session.NewSession(dbKind, cfg, resolver) + if err != nil { + return nil, err + } + return starrocksSession.DB, nil +} \ No newline at end of file diff --git a/common/persistence/sql/sqlplugin/starrocks/events.go b/common/persistence/sql/sqlplugin/starrocks/events.go new file mode 100644 index 00000000000..90bf3cc655a --- /dev/null +++ b/common/persistence/sql/sqlplugin/starrocks/events.go @@ -0,0 +1,109 @@ +// The MIT License +// +// Copyright (c) 2025 Temporal Technologies Inc. All rights reserved. +// +// Copyright (c) 2020 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +// The MIT License +// +// Copyright (c) 2025 Temporal Technologies Inc. All rights reserved. +// +// Copyright (c) 2020 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +package starrocks + +import ( + "github.com/jmoiron/sqlx" + "go.temporal.io/server/common/clock" + "go.temporal.io/server/common/config" + "go.temporal.io/server/common/log" + "go.temporal.io/server/common/metrics" + "go.temporal.io/server/common/persistence/sql" + "go.temporal.io/server/common/persistence/sql/sqlplugin" + "go.temporal.io/server/common/persistence/sql/sqlplugin/starrocks/session" + "go.temporal.io/server/common/resolver" +) + +const ( + // PluginName is the name of the plugin + PluginName = "starrocks" +) + +type plugin struct{} + +var _ sqlplugin.Plugin = (*plugin)(nil) + +func init() { + sql.RegisterPlugin(PluginName, &plugin{}) +} + +// CreateDB initialize the db object +func (p *plugin) CreateDB( + dbKind sqlplugin.DbKind, + cfg *config.SQL, + r resolver.ServiceResolver, + logger log.Logger, + metricsHandler metrics.Handler, +) (sqlplugin.GenericDB, error) { + connect := func() (*sqlx.DB, error) { + if cfg.Connect != nil { + return cfg.Connect(cfg) + } + return p.createDBConnection(dbKind, cfg, r) + } + handle := sqlplugin.NewDatabaseHandle(dbKind, connect, isConnNeedsRefreshError, logger, metricsHandler, clock.NewRealTimeSource()) + db := newDB(dbKind, cfg.DatabaseName, handle, nil) + return db, nil +} + +// CreateDBConnection creates a returns a reference to a logical connection to the +// underlying SQL database. The returned object is to tied to a single +// SQL database and the object can be used to perform CRUD operations on +// the tables in the database +func (p *plugin) createDBConnection( + dbKind sqlplugin.DbKind, + cfg *config.SQL, + resolver resolver.ServiceResolver, +) (*sqlx.DB, error) { + starrocksSession, err := session.NewSession(dbKind, cfg, resolver) + if err != nil { + return nil, err + } + return starrocksSession.DB, nil +} \ No newline at end of file diff --git a/common/persistence/sql/sqlplugin/starrocks/execution.go b/common/persistence/sql/sqlplugin/starrocks/execution.go new file mode 100644 index 00000000000..90bf3cc655a --- /dev/null +++ b/common/persistence/sql/sqlplugin/starrocks/execution.go @@ -0,0 +1,109 @@ +// The MIT License +// +// Copyright (c) 2025 Temporal Technologies Inc. All rights reserved. +// +// Copyright (c) 2020 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +// The MIT License +// +// Copyright (c) 2025 Temporal Technologies Inc. All rights reserved. +// +// Copyright (c) 2020 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +package starrocks + +import ( + "github.com/jmoiron/sqlx" + "go.temporal.io/server/common/clock" + "go.temporal.io/server/common/config" + "go.temporal.io/server/common/log" + "go.temporal.io/server/common/metrics" + "go.temporal.io/server/common/persistence/sql" + "go.temporal.io/server/common/persistence/sql/sqlplugin" + "go.temporal.io/server/common/persistence/sql/sqlplugin/starrocks/session" + "go.temporal.io/server/common/resolver" +) + +const ( + // PluginName is the name of the plugin + PluginName = "starrocks" +) + +type plugin struct{} + +var _ sqlplugin.Plugin = (*plugin)(nil) + +func init() { + sql.RegisterPlugin(PluginName, &plugin{}) +} + +// CreateDB initialize the db object +func (p *plugin) CreateDB( + dbKind sqlplugin.DbKind, + cfg *config.SQL, + r resolver.ServiceResolver, + logger log.Logger, + metricsHandler metrics.Handler, +) (sqlplugin.GenericDB, error) { + connect := func() (*sqlx.DB, error) { + if cfg.Connect != nil { + return cfg.Connect(cfg) + } + return p.createDBConnection(dbKind, cfg, r) + } + handle := sqlplugin.NewDatabaseHandle(dbKind, connect, isConnNeedsRefreshError, logger, metricsHandler, clock.NewRealTimeSource()) + db := newDB(dbKind, cfg.DatabaseName, handle, nil) + return db, nil +} + +// CreateDBConnection creates a returns a reference to a logical connection to the +// underlying SQL database. The returned object is to tied to a single +// SQL database and the object can be used to perform CRUD operations on +// the tables in the database +func (p *plugin) createDBConnection( + dbKind sqlplugin.DbKind, + cfg *config.SQL, + resolver resolver.ServiceResolver, +) (*sqlx.DB, error) { + starrocksSession, err := session.NewSession(dbKind, cfg, resolver) + if err != nil { + return nil, err + } + return starrocksSession.DB, nil +} \ No newline at end of file diff --git a/common/persistence/sql/sqlplugin/starrocks/execution_maps.go b/common/persistence/sql/sqlplugin/starrocks/execution_maps.go new file mode 100644 index 00000000000..90bf3cc655a --- /dev/null +++ b/common/persistence/sql/sqlplugin/starrocks/execution_maps.go @@ -0,0 +1,109 @@ +// The MIT License +// +// Copyright (c) 2025 Temporal Technologies Inc. All rights reserved. +// +// Copyright (c) 2020 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +// The MIT License +// +// Copyright (c) 2025 Temporal Technologies Inc. All rights reserved. +// +// Copyright (c) 2020 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +package starrocks + +import ( + "github.com/jmoiron/sqlx" + "go.temporal.io/server/common/clock" + "go.temporal.io/server/common/config" + "go.temporal.io/server/common/log" + "go.temporal.io/server/common/metrics" + "go.temporal.io/server/common/persistence/sql" + "go.temporal.io/server/common/persistence/sql/sqlplugin" + "go.temporal.io/server/common/persistence/sql/sqlplugin/starrocks/session" + "go.temporal.io/server/common/resolver" +) + +const ( + // PluginName is the name of the plugin + PluginName = "starrocks" +) + +type plugin struct{} + +var _ sqlplugin.Plugin = (*plugin)(nil) + +func init() { + sql.RegisterPlugin(PluginName, &plugin{}) +} + +// CreateDB initialize the db object +func (p *plugin) CreateDB( + dbKind sqlplugin.DbKind, + cfg *config.SQL, + r resolver.ServiceResolver, + logger log.Logger, + metricsHandler metrics.Handler, +) (sqlplugin.GenericDB, error) { + connect := func() (*sqlx.DB, error) { + if cfg.Connect != nil { + return cfg.Connect(cfg) + } + return p.createDBConnection(dbKind, cfg, r) + } + handle := sqlplugin.NewDatabaseHandle(dbKind, connect, isConnNeedsRefreshError, logger, metricsHandler, clock.NewRealTimeSource()) + db := newDB(dbKind, cfg.DatabaseName, handle, nil) + return db, nil +} + +// CreateDBConnection creates a returns a reference to a logical connection to the +// underlying SQL database. The returned object is to tied to a single +// SQL database and the object can be used to perform CRUD operations on +// the tables in the database +func (p *plugin) createDBConnection( + dbKind sqlplugin.DbKind, + cfg *config.SQL, + resolver resolver.ServiceResolver, +) (*sqlx.DB, error) { + starrocksSession, err := session.NewSession(dbKind, cfg, resolver) + if err != nil { + return nil, err + } + return starrocksSession.DB, nil +} \ No newline at end of file diff --git a/common/persistence/sql/sqlplugin/starrocks/namespace.go b/common/persistence/sql/sqlplugin/starrocks/namespace.go new file mode 100644 index 00000000000..90bf3cc655a --- /dev/null +++ b/common/persistence/sql/sqlplugin/starrocks/namespace.go @@ -0,0 +1,109 @@ +// The MIT License +// +// Copyright (c) 2025 Temporal Technologies Inc. All rights reserved. +// +// Copyright (c) 2020 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +// The MIT License +// +// Copyright (c) 2025 Temporal Technologies Inc. All rights reserved. +// +// Copyright (c) 2020 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +package starrocks + +import ( + "github.com/jmoiron/sqlx" + "go.temporal.io/server/common/clock" + "go.temporal.io/server/common/config" + "go.temporal.io/server/common/log" + "go.temporal.io/server/common/metrics" + "go.temporal.io/server/common/persistence/sql" + "go.temporal.io/server/common/persistence/sql/sqlplugin" + "go.temporal.io/server/common/persistence/sql/sqlplugin/starrocks/session" + "go.temporal.io/server/common/resolver" +) + +const ( + // PluginName is the name of the plugin + PluginName = "starrocks" +) + +type plugin struct{} + +var _ sqlplugin.Plugin = (*plugin)(nil) + +func init() { + sql.RegisterPlugin(PluginName, &plugin{}) +} + +// CreateDB initialize the db object +func (p *plugin) CreateDB( + dbKind sqlplugin.DbKind, + cfg *config.SQL, + r resolver.ServiceResolver, + logger log.Logger, + metricsHandler metrics.Handler, +) (sqlplugin.GenericDB, error) { + connect := func() (*sqlx.DB, error) { + if cfg.Connect != nil { + return cfg.Connect(cfg) + } + return p.createDBConnection(dbKind, cfg, r) + } + handle := sqlplugin.NewDatabaseHandle(dbKind, connect, isConnNeedsRefreshError, logger, metricsHandler, clock.NewRealTimeSource()) + db := newDB(dbKind, cfg.DatabaseName, handle, nil) + return db, nil +} + +// CreateDBConnection creates a returns a reference to a logical connection to the +// underlying SQL database. The returned object is to tied to a single +// SQL database and the object can be used to perform CRUD operations on +// the tables in the database +func (p *plugin) createDBConnection( + dbKind sqlplugin.DbKind, + cfg *config.SQL, + resolver resolver.ServiceResolver, +) (*sqlx.DB, error) { + starrocksSession, err := session.NewSession(dbKind, cfg, resolver) + if err != nil { + return nil, err + } + return starrocksSession.DB, nil +} \ No newline at end of file diff --git a/common/persistence/sql/sqlplugin/starrocks/nexus_endpoints.go b/common/persistence/sql/sqlplugin/starrocks/nexus_endpoints.go new file mode 100644 index 00000000000..90bf3cc655a --- /dev/null +++ b/common/persistence/sql/sqlplugin/starrocks/nexus_endpoints.go @@ -0,0 +1,109 @@ +// The MIT License +// +// Copyright (c) 2025 Temporal Technologies Inc. All rights reserved. +// +// Copyright (c) 2020 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +// The MIT License +// +// Copyright (c) 2025 Temporal Technologies Inc. All rights reserved. +// +// Copyright (c) 2020 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +package starrocks + +import ( + "github.com/jmoiron/sqlx" + "go.temporal.io/server/common/clock" + "go.temporal.io/server/common/config" + "go.temporal.io/server/common/log" + "go.temporal.io/server/common/metrics" + "go.temporal.io/server/common/persistence/sql" + "go.temporal.io/server/common/persistence/sql/sqlplugin" + "go.temporal.io/server/common/persistence/sql/sqlplugin/starrocks/session" + "go.temporal.io/server/common/resolver" +) + +const ( + // PluginName is the name of the plugin + PluginName = "starrocks" +) + +type plugin struct{} + +var _ sqlplugin.Plugin = (*plugin)(nil) + +func init() { + sql.RegisterPlugin(PluginName, &plugin{}) +} + +// CreateDB initialize the db object +func (p *plugin) CreateDB( + dbKind sqlplugin.DbKind, + cfg *config.SQL, + r resolver.ServiceResolver, + logger log.Logger, + metricsHandler metrics.Handler, +) (sqlplugin.GenericDB, error) { + connect := func() (*sqlx.DB, error) { + if cfg.Connect != nil { + return cfg.Connect(cfg) + } + return p.createDBConnection(dbKind, cfg, r) + } + handle := sqlplugin.NewDatabaseHandle(dbKind, connect, isConnNeedsRefreshError, logger, metricsHandler, clock.NewRealTimeSource()) + db := newDB(dbKind, cfg.DatabaseName, handle, nil) + return db, nil +} + +// CreateDBConnection creates a returns a reference to a logical connection to the +// underlying SQL database. The returned object is to tied to a single +// SQL database and the object can be used to perform CRUD operations on +// the tables in the database +func (p *plugin) createDBConnection( + dbKind sqlplugin.DbKind, + cfg *config.SQL, + resolver resolver.ServiceResolver, +) (*sqlx.DB, error) { + starrocksSession, err := session.NewSession(dbKind, cfg, resolver) + if err != nil { + return nil, err + } + return starrocksSession.DB, nil +} \ No newline at end of file diff --git a/common/persistence/sql/sqlplugin/starrocks/plugin.go b/common/persistence/sql/sqlplugin/starrocks/plugin.go new file mode 100644 index 00000000000..620d81b8598 --- /dev/null +++ b/common/persistence/sql/sqlplugin/starrocks/plugin.go @@ -0,0 +1,85 @@ +// The MIT License +// +// Copyright (c) 2025 Temporal Technologies Inc. All rights reserved. +// +// Copyright (c) 2020 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +package starrocks + +import ( + "github.com/jmoiron/sqlx" + "go.temporal.io/server/common/clock" + "go.temporal.io/server/common/config" + "go.temporal.io/server/common/log" + "go.temporal.io/server/common/metrics" + "go.temporal.io/server/common/persistence/sql" + "go.temporal.io/server/common/persistence/sql/sqlplugin" + "go.temporal.io/server/common/persistence/sql/sqlplugin/starrocks/session" + "go.temporal.io/server/common/resolver" +) + +const ( + // PluginName is the name of the plugin + PluginName = "starrocks" +) + +type plugin struct{} + +var _ sqlplugin.Plugin = (*plugin)(nil) + +func init() { + sql.RegisterPlugin(PluginName, &plugin{}) +} + +// CreateDB initialize the db object +func (p *plugin) CreateDB( + dbKind sqlplugin.DbKind, + cfg *config.SQL, + r resolver.ServiceResolver, + logger log.Logger, + metricsHandler metrics.Handler, +) (sqlplugin.GenericDB, error) { + connect := func() (*sqlx.DB, error) { + if cfg.Connect != nil { + return cfg.Connect(cfg) + } + return p.createDBConnection(dbKind, cfg, r) + } + handle := sqlplugin.NewDatabaseHandle(dbKind, connect, isConnNeedsRefreshError, logger, metricsHandler, clock.NewRealTimeSource()) + db := newDB(dbKind, cfg.DatabaseName, handle, nil) + return db, nil +} + +// CreateDBConnection creates a returns a reference to a logical connection to the +// underlying SQL database. The returned object is to tied to a single +// SQL database and the object can be used to perform CRUD operations on +// the tables in the database +func (p *plugin) createDBConnection( + dbKind sqlplugin.DbKind, + cfg *config.SQL, + resolver resolver.ServiceResolver, +) (*sqlx.DB, error) { + starrocksSession, err := session.NewSession(dbKind, cfg, resolver) + if err != nil { + return nil, err + } + return starrocksSession.DB, nil +} \ No newline at end of file diff --git a/common/persistence/sql/sqlplugin/starrocks/queue.go b/common/persistence/sql/sqlplugin/starrocks/queue.go new file mode 100644 index 00000000000..90bf3cc655a --- /dev/null +++ b/common/persistence/sql/sqlplugin/starrocks/queue.go @@ -0,0 +1,109 @@ +// The MIT License +// +// Copyright (c) 2025 Temporal Technologies Inc. All rights reserved. +// +// Copyright (c) 2020 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +// The MIT License +// +// Copyright (c) 2025 Temporal Technologies Inc. All rights reserved. +// +// Copyright (c) 2020 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +package starrocks + +import ( + "github.com/jmoiron/sqlx" + "go.temporal.io/server/common/clock" + "go.temporal.io/server/common/config" + "go.temporal.io/server/common/log" + "go.temporal.io/server/common/metrics" + "go.temporal.io/server/common/persistence/sql" + "go.temporal.io/server/common/persistence/sql/sqlplugin" + "go.temporal.io/server/common/persistence/sql/sqlplugin/starrocks/session" + "go.temporal.io/server/common/resolver" +) + +const ( + // PluginName is the name of the plugin + PluginName = "starrocks" +) + +type plugin struct{} + +var _ sqlplugin.Plugin = (*plugin)(nil) + +func init() { + sql.RegisterPlugin(PluginName, &plugin{}) +} + +// CreateDB initialize the db object +func (p *plugin) CreateDB( + dbKind sqlplugin.DbKind, + cfg *config.SQL, + r resolver.ServiceResolver, + logger log.Logger, + metricsHandler metrics.Handler, +) (sqlplugin.GenericDB, error) { + connect := func() (*sqlx.DB, error) { + if cfg.Connect != nil { + return cfg.Connect(cfg) + } + return p.createDBConnection(dbKind, cfg, r) + } + handle := sqlplugin.NewDatabaseHandle(dbKind, connect, isConnNeedsRefreshError, logger, metricsHandler, clock.NewRealTimeSource()) + db := newDB(dbKind, cfg.DatabaseName, handle, nil) + return db, nil +} + +// CreateDBConnection creates a returns a reference to a logical connection to the +// underlying SQL database. The returned object is to tied to a single +// SQL database and the object can be used to perform CRUD operations on +// the tables in the database +func (p *plugin) createDBConnection( + dbKind sqlplugin.DbKind, + cfg *config.SQL, + resolver resolver.ServiceResolver, +) (*sqlx.DB, error) { + starrocksSession, err := session.NewSession(dbKind, cfg, resolver) + if err != nil { + return nil, err + } + return starrocksSession.DB, nil +} \ No newline at end of file diff --git a/common/persistence/sql/sqlplugin/starrocks/queue_v2.go b/common/persistence/sql/sqlplugin/starrocks/queue_v2.go new file mode 100644 index 00000000000..90bf3cc655a --- /dev/null +++ b/common/persistence/sql/sqlplugin/starrocks/queue_v2.go @@ -0,0 +1,109 @@ +// The MIT License +// +// Copyright (c) 2025 Temporal Technologies Inc. All rights reserved. +// +// Copyright (c) 2020 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +// The MIT License +// +// Copyright (c) 2025 Temporal Technologies Inc. All rights reserved. +// +// Copyright (c) 2020 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +package starrocks + +import ( + "github.com/jmoiron/sqlx" + "go.temporal.io/server/common/clock" + "go.temporal.io/server/common/config" + "go.temporal.io/server/common/log" + "go.temporal.io/server/common/metrics" + "go.temporal.io/server/common/persistence/sql" + "go.temporal.io/server/common/persistence/sql/sqlplugin" + "go.temporal.io/server/common/persistence/sql/sqlplugin/starrocks/session" + "go.temporal.io/server/common/resolver" +) + +const ( + // PluginName is the name of the plugin + PluginName = "starrocks" +) + +type plugin struct{} + +var _ sqlplugin.Plugin = (*plugin)(nil) + +func init() { + sql.RegisterPlugin(PluginName, &plugin{}) +} + +// CreateDB initialize the db object +func (p *plugin) CreateDB( + dbKind sqlplugin.DbKind, + cfg *config.SQL, + r resolver.ServiceResolver, + logger log.Logger, + metricsHandler metrics.Handler, +) (sqlplugin.GenericDB, error) { + connect := func() (*sqlx.DB, error) { + if cfg.Connect != nil { + return cfg.Connect(cfg) + } + return p.createDBConnection(dbKind, cfg, r) + } + handle := sqlplugin.NewDatabaseHandle(dbKind, connect, isConnNeedsRefreshError, logger, metricsHandler, clock.NewRealTimeSource()) + db := newDB(dbKind, cfg.DatabaseName, handle, nil) + return db, nil +} + +// CreateDBConnection creates a returns a reference to a logical connection to the +// underlying SQL database. The returned object is to tied to a single +// SQL database and the object can be used to perform CRUD operations on +// the tables in the database +func (p *plugin) createDBConnection( + dbKind sqlplugin.DbKind, + cfg *config.SQL, + resolver resolver.ServiceResolver, +) (*sqlx.DB, error) { + starrocksSession, err := session.NewSession(dbKind, cfg, resolver) + if err != nil { + return nil, err + } + return starrocksSession.DB, nil +} \ No newline at end of file diff --git a/common/persistence/sql/sqlplugin/starrocks/session/session.go b/common/persistence/sql/sqlplugin/starrocks/session/session.go new file mode 100644 index 00000000000..90bf3cc655a --- /dev/null +++ b/common/persistence/sql/sqlplugin/starrocks/session/session.go @@ -0,0 +1,109 @@ +// The MIT License +// +// Copyright (c) 2025 Temporal Technologies Inc. All rights reserved. +// +// Copyright (c) 2020 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +// The MIT License +// +// Copyright (c) 2025 Temporal Technologies Inc. All rights reserved. +// +// Copyright (c) 2020 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +package starrocks + +import ( + "github.com/jmoiron/sqlx" + "go.temporal.io/server/common/clock" + "go.temporal.io/server/common/config" + "go.temporal.io/server/common/log" + "go.temporal.io/server/common/metrics" + "go.temporal.io/server/common/persistence/sql" + "go.temporal.io/server/common/persistence/sql/sqlplugin" + "go.temporal.io/server/common/persistence/sql/sqlplugin/starrocks/session" + "go.temporal.io/server/common/resolver" +) + +const ( + // PluginName is the name of the plugin + PluginName = "starrocks" +) + +type plugin struct{} + +var _ sqlplugin.Plugin = (*plugin)(nil) + +func init() { + sql.RegisterPlugin(PluginName, &plugin{}) +} + +// CreateDB initialize the db object +func (p *plugin) CreateDB( + dbKind sqlplugin.DbKind, + cfg *config.SQL, + r resolver.ServiceResolver, + logger log.Logger, + metricsHandler metrics.Handler, +) (sqlplugin.GenericDB, error) { + connect := func() (*sqlx.DB, error) { + if cfg.Connect != nil { + return cfg.Connect(cfg) + } + return p.createDBConnection(dbKind, cfg, r) + } + handle := sqlplugin.NewDatabaseHandle(dbKind, connect, isConnNeedsRefreshError, logger, metricsHandler, clock.NewRealTimeSource()) + db := newDB(dbKind, cfg.DatabaseName, handle, nil) + return db, nil +} + +// CreateDBConnection creates a returns a reference to a logical connection to the +// underlying SQL database. The returned object is to tied to a single +// SQL database and the object can be used to perform CRUD operations on +// the tables in the database +func (p *plugin) createDBConnection( + dbKind sqlplugin.DbKind, + cfg *config.SQL, + resolver resolver.ServiceResolver, +) (*sqlx.DB, error) { + starrocksSession, err := session.NewSession(dbKind, cfg, resolver) + if err != nil { + return nil, err + } + return starrocksSession.DB, nil +} \ No newline at end of file diff --git a/common/persistence/sql/sqlplugin/starrocks/shard.go b/common/persistence/sql/sqlplugin/starrocks/shard.go new file mode 100644 index 00000000000..90bf3cc655a --- /dev/null +++ b/common/persistence/sql/sqlplugin/starrocks/shard.go @@ -0,0 +1,109 @@ +// The MIT License +// +// Copyright (c) 2025 Temporal Technologies Inc. All rights reserved. +// +// Copyright (c) 2020 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +// The MIT License +// +// Copyright (c) 2025 Temporal Technologies Inc. All rights reserved. +// +// Copyright (c) 2020 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +package starrocks + +import ( + "github.com/jmoiron/sqlx" + "go.temporal.io/server/common/clock" + "go.temporal.io/server/common/config" + "go.temporal.io/server/common/log" + "go.temporal.io/server/common/metrics" + "go.temporal.io/server/common/persistence/sql" + "go.temporal.io/server/common/persistence/sql/sqlplugin" + "go.temporal.io/server/common/persistence/sql/sqlplugin/starrocks/session" + "go.temporal.io/server/common/resolver" +) + +const ( + // PluginName is the name of the plugin + PluginName = "starrocks" +) + +type plugin struct{} + +var _ sqlplugin.Plugin = (*plugin)(nil) + +func init() { + sql.RegisterPlugin(PluginName, &plugin{}) +} + +// CreateDB initialize the db object +func (p *plugin) CreateDB( + dbKind sqlplugin.DbKind, + cfg *config.SQL, + r resolver.ServiceResolver, + logger log.Logger, + metricsHandler metrics.Handler, +) (sqlplugin.GenericDB, error) { + connect := func() (*sqlx.DB, error) { + if cfg.Connect != nil { + return cfg.Connect(cfg) + } + return p.createDBConnection(dbKind, cfg, r) + } + handle := sqlplugin.NewDatabaseHandle(dbKind, connect, isConnNeedsRefreshError, logger, metricsHandler, clock.NewRealTimeSource()) + db := newDB(dbKind, cfg.DatabaseName, handle, nil) + return db, nil +} + +// CreateDBConnection creates a returns a reference to a logical connection to the +// underlying SQL database. The returned object is to tied to a single +// SQL database and the object can be used to perform CRUD operations on +// the tables in the database +func (p *plugin) createDBConnection( + dbKind sqlplugin.DbKind, + cfg *config.SQL, + resolver resolver.ServiceResolver, +) (*sqlx.DB, error) { + starrocksSession, err := session.NewSession(dbKind, cfg, resolver) + if err != nil { + return nil, err + } + return starrocksSession.DB, nil +} \ No newline at end of file diff --git a/common/persistence/sql/sqlplugin/starrocks/task_queues.go b/common/persistence/sql/sqlplugin/starrocks/task_queues.go new file mode 100644 index 00000000000..90bf3cc655a --- /dev/null +++ b/common/persistence/sql/sqlplugin/starrocks/task_queues.go @@ -0,0 +1,109 @@ +// The MIT License +// +// Copyright (c) 2025 Temporal Technologies Inc. All rights reserved. +// +// Copyright (c) 2020 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +// The MIT License +// +// Copyright (c) 2025 Temporal Technologies Inc. All rights reserved. +// +// Copyright (c) 2020 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +package starrocks + +import ( + "github.com/jmoiron/sqlx" + "go.temporal.io/server/common/clock" + "go.temporal.io/server/common/config" + "go.temporal.io/server/common/log" + "go.temporal.io/server/common/metrics" + "go.temporal.io/server/common/persistence/sql" + "go.temporal.io/server/common/persistence/sql/sqlplugin" + "go.temporal.io/server/common/persistence/sql/sqlplugin/starrocks/session" + "go.temporal.io/server/common/resolver" +) + +const ( + // PluginName is the name of the plugin + PluginName = "starrocks" +) + +type plugin struct{} + +var _ sqlplugin.Plugin = (*plugin)(nil) + +func init() { + sql.RegisterPlugin(PluginName, &plugin{}) +} + +// CreateDB initialize the db object +func (p *plugin) CreateDB( + dbKind sqlplugin.DbKind, + cfg *config.SQL, + r resolver.ServiceResolver, + logger log.Logger, + metricsHandler metrics.Handler, +) (sqlplugin.GenericDB, error) { + connect := func() (*sqlx.DB, error) { + if cfg.Connect != nil { + return cfg.Connect(cfg) + } + return p.createDBConnection(dbKind, cfg, r) + } + handle := sqlplugin.NewDatabaseHandle(dbKind, connect, isConnNeedsRefreshError, logger, metricsHandler, clock.NewRealTimeSource()) + db := newDB(dbKind, cfg.DatabaseName, handle, nil) + return db, nil +} + +// CreateDBConnection creates a returns a reference to a logical connection to the +// underlying SQL database. The returned object is to tied to a single +// SQL database and the object can be used to perform CRUD operations on +// the tables in the database +func (p *plugin) createDBConnection( + dbKind sqlplugin.DbKind, + cfg *config.SQL, + resolver resolver.ServiceResolver, +) (*sqlx.DB, error) { + starrocksSession, err := session.NewSession(dbKind, cfg, resolver) + if err != nil { + return nil, err + } + return starrocksSession.DB, nil +} \ No newline at end of file diff --git a/common/persistence/sql/sqlplugin/starrocks/task_user_data.go b/common/persistence/sql/sqlplugin/starrocks/task_user_data.go new file mode 100644 index 00000000000..90bf3cc655a --- /dev/null +++ b/common/persistence/sql/sqlplugin/starrocks/task_user_data.go @@ -0,0 +1,109 @@ +// The MIT License +// +// Copyright (c) 2025 Temporal Technologies Inc. All rights reserved. +// +// Copyright (c) 2020 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +// The MIT License +// +// Copyright (c) 2025 Temporal Technologies Inc. All rights reserved. +// +// Copyright (c) 2020 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +package starrocks + +import ( + "github.com/jmoiron/sqlx" + "go.temporal.io/server/common/clock" + "go.temporal.io/server/common/config" + "go.temporal.io/server/common/log" + "go.temporal.io/server/common/metrics" + "go.temporal.io/server/common/persistence/sql" + "go.temporal.io/server/common/persistence/sql/sqlplugin" + "go.temporal.io/server/common/persistence/sql/sqlplugin/starrocks/session" + "go.temporal.io/server/common/resolver" +) + +const ( + // PluginName is the name of the plugin + PluginName = "starrocks" +) + +type plugin struct{} + +var _ sqlplugin.Plugin = (*plugin)(nil) + +func init() { + sql.RegisterPlugin(PluginName, &plugin{}) +} + +// CreateDB initialize the db object +func (p *plugin) CreateDB( + dbKind sqlplugin.DbKind, + cfg *config.SQL, + r resolver.ServiceResolver, + logger log.Logger, + metricsHandler metrics.Handler, +) (sqlplugin.GenericDB, error) { + connect := func() (*sqlx.DB, error) { + if cfg.Connect != nil { + return cfg.Connect(cfg) + } + return p.createDBConnection(dbKind, cfg, r) + } + handle := sqlplugin.NewDatabaseHandle(dbKind, connect, isConnNeedsRefreshError, logger, metricsHandler, clock.NewRealTimeSource()) + db := newDB(dbKind, cfg.DatabaseName, handle, nil) + return db, nil +} + +// CreateDBConnection creates a returns a reference to a logical connection to the +// underlying SQL database. The returned object is to tied to a single +// SQL database and the object can be used to perform CRUD operations on +// the tables in the database +func (p *plugin) createDBConnection( + dbKind sqlplugin.DbKind, + cfg *config.SQL, + resolver resolver.ServiceResolver, +) (*sqlx.DB, error) { + starrocksSession, err := session.NewSession(dbKind, cfg, resolver) + if err != nil { + return nil, err + } + return starrocksSession.DB, nil +} \ No newline at end of file diff --git a/common/persistence/sql/sqlplugin/starrocks/task_v1.go b/common/persistence/sql/sqlplugin/starrocks/task_v1.go new file mode 100644 index 00000000000..90bf3cc655a --- /dev/null +++ b/common/persistence/sql/sqlplugin/starrocks/task_v1.go @@ -0,0 +1,109 @@ +// The MIT License +// +// Copyright (c) 2025 Temporal Technologies Inc. All rights reserved. +// +// Copyright (c) 2020 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +// The MIT License +// +// Copyright (c) 2025 Temporal Technologies Inc. All rights reserved. +// +// Copyright (c) 2020 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +package starrocks + +import ( + "github.com/jmoiron/sqlx" + "go.temporal.io/server/common/clock" + "go.temporal.io/server/common/config" + "go.temporal.io/server/common/log" + "go.temporal.io/server/common/metrics" + "go.temporal.io/server/common/persistence/sql" + "go.temporal.io/server/common/persistence/sql/sqlplugin" + "go.temporal.io/server/common/persistence/sql/sqlplugin/starrocks/session" + "go.temporal.io/server/common/resolver" +) + +const ( + // PluginName is the name of the plugin + PluginName = "starrocks" +) + +type plugin struct{} + +var _ sqlplugin.Plugin = (*plugin)(nil) + +func init() { + sql.RegisterPlugin(PluginName, &plugin{}) +} + +// CreateDB initialize the db object +func (p *plugin) CreateDB( + dbKind sqlplugin.DbKind, + cfg *config.SQL, + r resolver.ServiceResolver, + logger log.Logger, + metricsHandler metrics.Handler, +) (sqlplugin.GenericDB, error) { + connect := func() (*sqlx.DB, error) { + if cfg.Connect != nil { + return cfg.Connect(cfg) + } + return p.createDBConnection(dbKind, cfg, r) + } + handle := sqlplugin.NewDatabaseHandle(dbKind, connect, isConnNeedsRefreshError, logger, metricsHandler, clock.NewRealTimeSource()) + db := newDB(dbKind, cfg.DatabaseName, handle, nil) + return db, nil +} + +// CreateDBConnection creates a returns a reference to a logical connection to the +// underlying SQL database. The returned object is to tied to a single +// SQL database and the object can be used to perform CRUD operations on +// the tables in the database +func (p *plugin) createDBConnection( + dbKind sqlplugin.DbKind, + cfg *config.SQL, + resolver resolver.ServiceResolver, +) (*sqlx.DB, error) { + starrocksSession, err := session.NewSession(dbKind, cfg, resolver) + if err != nil { + return nil, err + } + return starrocksSession.DB, nil +} \ No newline at end of file diff --git a/common/persistence/sql/sqlplugin/starrocks/task_v2.go b/common/persistence/sql/sqlplugin/starrocks/task_v2.go new file mode 100644 index 00000000000..90bf3cc655a --- /dev/null +++ b/common/persistence/sql/sqlplugin/starrocks/task_v2.go @@ -0,0 +1,109 @@ +// The MIT License +// +// Copyright (c) 2025 Temporal Technologies Inc. All rights reserved. +// +// Copyright (c) 2020 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +// The MIT License +// +// Copyright (c) 2025 Temporal Technologies Inc. All rights reserved. +// +// Copyright (c) 2020 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +package starrocks + +import ( + "github.com/jmoiron/sqlx" + "go.temporal.io/server/common/clock" + "go.temporal.io/server/common/config" + "go.temporal.io/server/common/log" + "go.temporal.io/server/common/metrics" + "go.temporal.io/server/common/persistence/sql" + "go.temporal.io/server/common/persistence/sql/sqlplugin" + "go.temporal.io/server/common/persistence/sql/sqlplugin/starrocks/session" + "go.temporal.io/server/common/resolver" +) + +const ( + // PluginName is the name of the plugin + PluginName = "starrocks" +) + +type plugin struct{} + +var _ sqlplugin.Plugin = (*plugin)(nil) + +func init() { + sql.RegisterPlugin(PluginName, &plugin{}) +} + +// CreateDB initialize the db object +func (p *plugin) CreateDB( + dbKind sqlplugin.DbKind, + cfg *config.SQL, + r resolver.ServiceResolver, + logger log.Logger, + metricsHandler metrics.Handler, +) (sqlplugin.GenericDB, error) { + connect := func() (*sqlx.DB, error) { + if cfg.Connect != nil { + return cfg.Connect(cfg) + } + return p.createDBConnection(dbKind, cfg, r) + } + handle := sqlplugin.NewDatabaseHandle(dbKind, connect, isConnNeedsRefreshError, logger, metricsHandler, clock.NewRealTimeSource()) + db := newDB(dbKind, cfg.DatabaseName, handle, nil) + return db, nil +} + +// CreateDBConnection creates a returns a reference to a logical connection to the +// underlying SQL database. The returned object is to tied to a single +// SQL database and the object can be used to perform CRUD operations on +// the tables in the database +func (p *plugin) createDBConnection( + dbKind sqlplugin.DbKind, + cfg *config.SQL, + resolver resolver.ServiceResolver, +) (*sqlx.DB, error) { + starrocksSession, err := session.NewSession(dbKind, cfg, resolver) + if err != nil { + return nil, err + } + return starrocksSession.DB, nil +} \ No newline at end of file diff --git a/common/persistence/sql/sqlplugin/starrocks/typeconv.go b/common/persistence/sql/sqlplugin/starrocks/typeconv.go new file mode 100644 index 00000000000..90bf3cc655a --- /dev/null +++ b/common/persistence/sql/sqlplugin/starrocks/typeconv.go @@ -0,0 +1,109 @@ +// The MIT License +// +// Copyright (c) 2025 Temporal Technologies Inc. All rights reserved. +// +// Copyright (c) 2020 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +// The MIT License +// +// Copyright (c) 2025 Temporal Technologies Inc. All rights reserved. +// +// Copyright (c) 2020 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +package starrocks + +import ( + "github.com/jmoiron/sqlx" + "go.temporal.io/server/common/clock" + "go.temporal.io/server/common/config" + "go.temporal.io/server/common/log" + "go.temporal.io/server/common/metrics" + "go.temporal.io/server/common/persistence/sql" + "go.temporal.io/server/common/persistence/sql/sqlplugin" + "go.temporal.io/server/common/persistence/sql/sqlplugin/starrocks/session" + "go.temporal.io/server/common/resolver" +) + +const ( + // PluginName is the name of the plugin + PluginName = "starrocks" +) + +type plugin struct{} + +var _ sqlplugin.Plugin = (*plugin)(nil) + +func init() { + sql.RegisterPlugin(PluginName, &plugin{}) +} + +// CreateDB initialize the db object +func (p *plugin) CreateDB( + dbKind sqlplugin.DbKind, + cfg *config.SQL, + r resolver.ServiceResolver, + logger log.Logger, + metricsHandler metrics.Handler, +) (sqlplugin.GenericDB, error) { + connect := func() (*sqlx.DB, error) { + if cfg.Connect != nil { + return cfg.Connect(cfg) + } + return p.createDBConnection(dbKind, cfg, r) + } + handle := sqlplugin.NewDatabaseHandle(dbKind, connect, isConnNeedsRefreshError, logger, metricsHandler, clock.NewRealTimeSource()) + db := newDB(dbKind, cfg.DatabaseName, handle, nil) + return db, nil +} + +// CreateDBConnection creates a returns a reference to a logical connection to the +// underlying SQL database. The returned object is to tied to a single +// SQL database and the object can be used to perform CRUD operations on +// the tables in the database +func (p *plugin) createDBConnection( + dbKind sqlplugin.DbKind, + cfg *config.SQL, + resolver resolver.ServiceResolver, +) (*sqlx.DB, error) { + starrocksSession, err := session.NewSession(dbKind, cfg, resolver) + if err != nil { + return nil, err + } + return starrocksSession.DB, nil +} \ No newline at end of file diff --git a/common/persistence/sql/sqlplugin/starrocks/visibility.go b/common/persistence/sql/sqlplugin/starrocks/visibility.go new file mode 100644 index 00000000000..90bf3cc655a --- /dev/null +++ b/common/persistence/sql/sqlplugin/starrocks/visibility.go @@ -0,0 +1,109 @@ +// The MIT License +// +// Copyright (c) 2025 Temporal Technologies Inc. All rights reserved. +// +// Copyright (c) 2020 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +// The MIT License +// +// Copyright (c) 2025 Temporal Technologies Inc. All rights reserved. +// +// Copyright (c) 2020 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +package starrocks + +import ( + "github.com/jmoiron/sqlx" + "go.temporal.io/server/common/clock" + "go.temporal.io/server/common/config" + "go.temporal.io/server/common/log" + "go.temporal.io/server/common/metrics" + "go.temporal.io/server/common/persistence/sql" + "go.temporal.io/server/common/persistence/sql/sqlplugin" + "go.temporal.io/server/common/persistence/sql/sqlplugin/starrocks/session" + "go.temporal.io/server/common/resolver" +) + +const ( + // PluginName is the name of the plugin + PluginName = "starrocks" +) + +type plugin struct{} + +var _ sqlplugin.Plugin = (*plugin)(nil) + +func init() { + sql.RegisterPlugin(PluginName, &plugin{}) +} + +// CreateDB initialize the db object +func (p *plugin) CreateDB( + dbKind sqlplugin.DbKind, + cfg *config.SQL, + r resolver.ServiceResolver, + logger log.Logger, + metricsHandler metrics.Handler, +) (sqlplugin.GenericDB, error) { + connect := func() (*sqlx.DB, error) { + if cfg.Connect != nil { + return cfg.Connect(cfg) + } + return p.createDBConnection(dbKind, cfg, r) + } + handle := sqlplugin.NewDatabaseHandle(dbKind, connect, isConnNeedsRefreshError, logger, metricsHandler, clock.NewRealTimeSource()) + db := newDB(dbKind, cfg.DatabaseName, handle, nil) + return db, nil +} + +// CreateDBConnection creates a returns a reference to a logical connection to the +// underlying SQL database. The returned object is to tied to a single +// SQL database and the object can be used to perform CRUD operations on +// the tables in the database +func (p *plugin) createDBConnection( + dbKind sqlplugin.DbKind, + cfg *config.SQL, + resolver resolver.ServiceResolver, +) (*sqlx.DB, error) { + starrocksSession, err := session.NewSession(dbKind, cfg, resolver) + if err != nil { + return nil, err + } + return starrocksSession.DB, nil +} \ No newline at end of file diff --git a/config/development-starrocks.yaml b/config/development-starrocks.yaml new file mode 100644 index 00000000000..0cfa2f94b13 --- /dev/null +++ b/config/development-starrocks.yaml @@ -0,0 +1,119 @@ +log: + stdout: true + level: info + +persistence: + defaultStore: starrocks-default + visibilityStore: starrocks-visibility + numHistoryShards: 1 + datastores: + starrocks-default: + sql: + user: "root" + password: "" + pluginName: "starrocks" + databaseName: "temporal" + connectAddr: "localhost:9030" + connectProtocol: "tcp" + connectAttributes: + # StarRocks specific connection attributes + autocommit: "true" + maxConns: 20 + maxIdleConns: 5 + maxConnLifetime: "1h" + tls: + enabled: false + caFile: "" + certFile: "" + keyFile: "" + enableHostVerification: false + serverName: "" + + starrocks-visibility: + sql: + user: "root" + password: "" + pluginName: "starrocks" + databaseName: "temporal_visibility" + connectAddr: "localhost:9030" + connectProtocol: "tcp" + connectAttributes: + # StarRocks specific connection attributes + autocommit: "true" + maxConns: 20 + maxIdleConns: 5 + maxConnLifetime: "1h" + tls: + enabled: false + caFile: "" + certFile: "" + keyFile: "" + enableHostVerification: false + serverName: "" + +services: + frontend: + rpc: + grpcPort: 7233 + membershipPort: 6933 + bindOnLocalHost: true + bindOnIP: "0.0.0.0" + + matching: + rpc: + grpcPort: 7235 + membershipPort: 6935 + bindOnLocalHost: true + bindOnIP: "0.0.0.0" + + history: + rpc: + grpcPort: 7234 + membershipPort: 6934 + bindOnLocalHost: true + bindOnIP: "0.0.0.0" + + worker: + rpc: + grpcPort: 7239 + membershipPort: 6939 + bindOnLocalHost: true + bindOnIP: "0.0.0.0" + +clusterMetadata: + enableGlobalNamespace: false + failoverVersionIncrement: 10 + masterClusterName: "active" + currentClusterName: "active" + clusterInformation: + active: + enabled: true + initialFailoverVersion: 1 + rpcName: "frontend" + rpcAddress: "127.0.0.1:7233" + +dcRedirectionPolicy: + policy: "noop" + +archival: + history: + state: "disabled" + enableRead: false + provider: + filestore: + fileMode: "0666" + dirMode: "0766" + visibility: + state: "disabled" + enableRead: false + provider: + filestore: + fileMode: "0666" + dirMode: "0766" + +publicClient: + hostPort: "127.0.0.1:7233" + +dynamicConfigClient: + filepath: "config/dynamicconfig/development-sql.yaml" + pollInterval: "10s" diff --git a/schema/starrocks/temporal/database.sql b/schema/starrocks/temporal/database.sql new file mode 100644 index 00000000000..f38c409fa70 --- /dev/null +++ b/schema/starrocks/temporal/database.sql @@ -0,0 +1 @@ +CREATE DATABASE temporal CHARACTER SET utf8mb4; diff --git a/schema/starrocks/temporal/schema.sql b/schema/starrocks/temporal/schema.sql new file mode 100644 index 00000000000..05f6913b77c --- /dev/null +++ b/schema/starrocks/temporal/schema.sql @@ -0,0 +1,396 @@ +CREATE TABLE namespaces( + partition_id INT NOT NULL, + id BINARY(16) NOT NULL, + name VARCHAR(255) UNIQUE NOT NULL, + notification_version BIGINT NOT NULL, + -- + data MEDIUMBLOB NOT NULL, + data_encoding VARCHAR(16) NOT NULL, + is_global TINYINT(1) NOT NULL, + PRIMARY KEY(partition_id, id) +); + +CREATE TABLE namespace_metadata ( + partition_id INT NOT NULL, + notification_version BIGINT NOT NULL, + PRIMARY KEY(partition_id) +); + +INSERT INTO namespace_metadata (partition_id, notification_version) VALUES (54321, 1); + +CREATE TABLE shards ( + shard_id INT NOT NULL, + -- + range_id BIGINT NOT NULL, + data MEDIUMBLOB NOT NULL, + data_encoding VARCHAR(16) NOT NULL, + PRIMARY KEY (shard_id) +); + +CREATE TABLE executions( + shard_id INT NOT NULL, + namespace_id BINARY(16) NOT NULL, + workflow_id VARCHAR(255) NOT NULL, + run_id BINARY(16) NOT NULL, + -- + next_event_id BIGINT NOT NULL, + last_write_version BIGINT NOT NULL, + data MEDIUMBLOB NOT NULL, + data_encoding VARCHAR(16) NOT NULL, + state MEDIUMBLOB NOT NULL, + state_encoding VARCHAR(16) NOT NULL, + db_record_version BIGINT NOT NULL DEFAULT 0, + PRIMARY KEY (shard_id, namespace_id, workflow_id, run_id) +); + +CREATE TABLE current_executions( + shard_id INT NOT NULL, + namespace_id BINARY(16) NOT NULL, + workflow_id VARCHAR(255) NOT NULL, + -- + run_id BINARY(16) NOT NULL, + create_request_id VARCHAR(255) NOT NULL, + state INT NOT NULL, + status INT NOT NULL, + start_version BIGINT NOT NULL DEFAULT 0, + start_time DATETIME(6), + last_write_version BIGINT NOT NULL, + -- `data` contains the WorkflowExecutionState (same as in `executions.state` above) + data MEDIUMBLOB NULL, + data_encoding VARCHAR(16) NOT NULL DEFAULT '', + PRIMARY KEY (shard_id, namespace_id, workflow_id) +); + +CREATE TABLE buffered_events ( + shard_id INT NOT NULL, + namespace_id BINARY(16) NOT NULL, + workflow_id VARCHAR(255) NOT NULL, + run_id BINARY(16) NOT NULL, + id BIGINT AUTO_INCREMENT NOT NULL UNIQUE, + -- + data MEDIUMBLOB NOT NULL, + data_encoding VARCHAR(16) NOT NULL, + PRIMARY KEY (shard_id, namespace_id, workflow_id, run_id, id) +); + +CREATE TABLE tasks ( + range_hash INT UNSIGNED NOT NULL, + task_queue_id VARBINARY(272) NOT NULL, + task_id BIGINT NOT NULL, + -- + data MEDIUMBLOB NOT NULL, + data_encoding VARCHAR(16) NOT NULL, + PRIMARY KEY (range_hash, task_queue_id, task_id) +); + +-- Stores ephemeral task queue information such as ack levels and expiry times +CREATE TABLE task_queues ( + range_hash INT UNSIGNED NOT NULL, + task_queue_id VARBINARY(272) NOT NULL, + -- + range_id BIGINT NOT NULL, + data MEDIUMBLOB NOT NULL, + data_encoding VARCHAR(16) NOT NULL, + PRIMARY KEY (range_hash, task_queue_id) +); + +-- Stores activity or workflow tasks +-- Used for fairness scheduling. (pass, task_id) are monotonically increasing. +CREATE TABLE tasks_v2 ( + range_hash INT UNSIGNED NOT NULL, + task_queue_id VARBINARY(272) NOT NULL, + pass BIGINT NOT NULL, -- pass for tasks (see stride scheduling algorithm for fairness) + task_id BIGINT NOT NULL, + -- + data MEDIUMBLOB NOT NULL, + data_encoding VARCHAR(16) NOT NULL, + PRIMARY KEY (range_hash, task_queue_id, pass, task_id) +); + +-- Stores ephemeral task queue information such as ack levels and expiry times +CREATE TABLE task_queues_v2 ( + range_hash INT UNSIGNED NOT NULL, + task_queue_id VARBINARY(272) NOT NULL, + -- + range_id BIGINT NOT NULL, + data MEDIUMBLOB NOT NULL, + data_encoding VARCHAR(16) NOT NULL, + PRIMARY KEY (range_hash, task_queue_id) +); + +-- Stores task queue information such as user provided versioning data +CREATE TABLE task_queue_user_data ( + namespace_id BINARY(16) NOT NULL, + task_queue_name VARCHAR(255) NOT NULL, + data MEDIUMBLOB NOT NULL, -- temporal.server.api.persistence.v1.TaskQueueUserData + data_encoding VARCHAR(16) NOT NULL, -- Encoding type used for serialization, in practice this should always be proto3 + version BIGINT NOT NULL, -- Version of this row, used for optimistic concurrency + PRIMARY KEY (namespace_id, task_queue_name) +); + +-- Stores a mapping between build ids and task queues +CREATE TABLE build_id_to_task_queue ( + namespace_id BINARY(16) NOT NULL, + build_id VARCHAR(255) NOT NULL, + task_queue_name VARCHAR(255) NOT NULL, + PRIMARY KEY (namespace_id, build_id, task_queue_name) +); + +CREATE TABLE history_immediate_tasks( + shard_id INT NOT NULL, + category_id INT NOT NULL, + task_id BIGINT NOT NULL, + -- + data MEDIUMBLOB NOT NULL, + data_encoding VARCHAR(16) NOT NULL, + PRIMARY KEY (shard_id, category_id, task_id) +); + +CREATE TABLE history_scheduled_tasks ( + shard_id INT NOT NULL, + category_id INT NOT NULL, + visibility_timestamp DATETIME(6) NOT NULL, + task_id BIGINT NOT NULL, + -- + data MEDIUMBLOB NOT NULL, + data_encoding VARCHAR(16) NOT NULL, + PRIMARY KEY (shard_id, category_id, visibility_timestamp, task_id) +); + +CREATE TABLE transfer_tasks( + shard_id INT NOT NULL, + task_id BIGINT NOT NULL, + -- + data MEDIUMBLOB NOT NULL, + data_encoding VARCHAR(16) NOT NULL, + PRIMARY KEY (shard_id, task_id) +); + +CREATE TABLE timer_tasks ( + shard_id INT NOT NULL, + visibility_timestamp DATETIME(6) NOT NULL, + task_id BIGINT NOT NULL, + -- + data MEDIUMBLOB NOT NULL, + data_encoding VARCHAR(16) NOT NULL, + PRIMARY KEY (shard_id, visibility_timestamp, task_id) +); + +CREATE TABLE replication_tasks ( + shard_id INT NOT NULL, + task_id BIGINT NOT NULL, + -- + data MEDIUMBLOB NOT NULL, + data_encoding VARCHAR(16) NOT NULL, + PRIMARY KEY (shard_id, task_id) +); + +CREATE TABLE replication_tasks_dlq ( + source_cluster_name VARCHAR(255) NOT NULL, + shard_id INT NOT NULL, + task_id BIGINT NOT NULL, + -- + data MEDIUMBLOB NOT NULL, + data_encoding VARCHAR(16) NOT NULL, + PRIMARY KEY (source_cluster_name, shard_id, task_id) +); + +CREATE TABLE visibility_tasks( + shard_id INT NOT NULL, + task_id BIGINT NOT NULL, + -- + data MEDIUMBLOB NOT NULL, + data_encoding VARCHAR(16) NOT NULL, + PRIMARY KEY (shard_id, task_id) +); + +CREATE TABLE activity_info_maps ( +-- each row corresponds to one key of one map + shard_id INT NOT NULL, + namespace_id BINARY(16) NOT NULL, + workflow_id VARCHAR(255) NOT NULL, + run_id BINARY(16) NOT NULL, + schedule_id BIGINT NOT NULL, +-- + data MEDIUMBLOB NOT NULL, + data_encoding VARCHAR(16), + PRIMARY KEY (shard_id, namespace_id, workflow_id, run_id, schedule_id) +); + +CREATE TABLE timer_info_maps ( + shard_id INT NOT NULL, + namespace_id BINARY(16) NOT NULL, + workflow_id VARCHAR(255) NOT NULL, + run_id BINARY(16) NOT NULL, + timer_id VARCHAR(255) NOT NULL, +-- + data MEDIUMBLOB NOT NULL, + data_encoding VARCHAR(16), + PRIMARY KEY (shard_id, namespace_id, workflow_id, run_id, timer_id) +); + +CREATE TABLE child_execution_info_maps ( + shard_id INT NOT NULL, + namespace_id BINARY(16) NOT NULL, + workflow_id VARCHAR(255) NOT NULL, + run_id BINARY(16) NOT NULL, + initiated_id BIGINT NOT NULL, +-- + data MEDIUMBLOB NOT NULL, + data_encoding VARCHAR(16), + PRIMARY KEY (shard_id, namespace_id, workflow_id, run_id, initiated_id) +); + +CREATE TABLE request_cancel_info_maps ( + shard_id INT NOT NULL, + namespace_id BINARY(16) NOT NULL, + workflow_id VARCHAR(255) NOT NULL, + run_id BINARY(16) NOT NULL, + initiated_id BIGINT NOT NULL, +-- + data MEDIUMBLOB NOT NULL, + data_encoding VARCHAR(16), + PRIMARY KEY (shard_id, namespace_id, workflow_id, run_id, initiated_id) +); + +CREATE TABLE signal_info_maps ( + shard_id INT NOT NULL, + namespace_id BINARY(16) NOT NULL, + workflow_id VARCHAR(255) NOT NULL, + run_id BINARY(16) NOT NULL, + initiated_id BIGINT NOT NULL, +-- + data MEDIUMBLOB NOT NULL, + data_encoding VARCHAR(16), + PRIMARY KEY (shard_id, namespace_id, workflow_id, run_id, initiated_id) +); + +CREATE TABLE signals_requested_sets ( + shard_id INT NOT NULL, + namespace_id BINARY(16) NOT NULL, + workflow_id VARCHAR(255) NOT NULL, + run_id BINARY(16) NOT NULL, + signal_id VARCHAR(255) NOT NULL, + -- + PRIMARY KEY (shard_id, namespace_id, workflow_id, run_id, signal_id) +); + +CREATE TABLE chasm_node_maps ( + shard_id INT NOT NULL, + namespace_id BINARY(16) NOT NULL, + workflow_id VARCHAR(255) NOT NULL, + run_id BINARY(16) NOT NULL, + chasm_path VARBINARY(1536) NOT NULL, +-- + metadata MEDIUMBLOB NOT NULL, + metadata_encoding VARCHAR(16), + data MEDIUMBLOB, + data_encoding VARCHAR(16), + PRIMARY KEY (shard_id, namespace_id, workflow_id, run_id, chasm_path) +); + +-- history eventsV2: history_node stores history event data +CREATE TABLE history_node ( + shard_id INT NOT NULL, + tree_id BINARY(16) NOT NULL, + branch_id BINARY(16) NOT NULL, + node_id BIGINT NOT NULL, + txn_id BIGINT NOT NULL, + -- + prev_txn_id BIGINT NOT NULL DEFAULT 0, + data MEDIUMBLOB NOT NULL, + data_encoding VARCHAR(16) NOT NULL, + PRIMARY KEY (shard_id, tree_id, branch_id, node_id, txn_id) +); + +-- history eventsV2: history_tree stores branch metadata +CREATE TABLE history_tree ( + shard_id INT NOT NULL, + tree_id BINARY(16) NOT NULL, + branch_id BINARY(16) NOT NULL, + -- + data MEDIUMBLOB NOT NULL, + data_encoding VARCHAR(16) NOT NULL, + PRIMARY KEY (shard_id, tree_id, branch_id) +); + +CREATE TABLE queue ( + queue_type INT NOT NULL, + message_id BIGINT NOT NULL, + message_payload MEDIUMBLOB NOT NULL, + message_encoding VARCHAR(16) NOT NULL, + PRIMARY KEY(queue_type, message_id) +); + +CREATE TABLE queue_metadata ( + queue_type INT NOT NULL, + data MEDIUMBLOB NOT NULL, + data_encoding VARCHAR(16) NOT NULL, + version BIGINT NOT NULL, + PRIMARY KEY(queue_type) +); + +CREATE TABLE cluster_metadata_info ( + metadata_partition INT NOT NULL, + cluster_name VARCHAR(255) NOT NULL, + data MEDIUMBLOB NOT NULL, + data_encoding VARCHAR(16) NOT NULL, + version BIGINT NOT NULL, + PRIMARY KEY(metadata_partition, cluster_name) +); + +CREATE TABLE cluster_membership ( + membership_partition INT NOT NULL, + host_id BINARY(16) NOT NULL, + rpc_address VARCHAR(128) NOT NULL, + rpc_port SMALLINT NOT NULL, + role TINYINT NOT NULL, + session_start TIMESTAMP DEFAULT '1970-01-02 00:00:01', + last_heartbeat TIMESTAMP DEFAULT '1970-01-02 00:00:01', + record_expiry TIMESTAMP DEFAULT '1970-01-02 00:00:01', + INDEX (role, host_id), + INDEX (role, last_heartbeat), + INDEX (rpc_address, role), + INDEX (last_heartbeat), + INDEX (record_expiry), + PRIMARY KEY (membership_partition, host_id) +); + +CREATE TABLE queues ( + queue_type INT NOT NULL, + queue_name VARCHAR(255) NOT NULL, + metadata_payload MEDIUMBLOB NOT NULL, + metadata_encoding VARCHAR(16) NOT NULL, + PRIMARY KEY (queue_type, queue_name) +); + +CREATE TABLE queue_messages ( + queue_type INT NOT NULL, + queue_name VARCHAR(255) NOT NULL, + queue_partition BIGINT NOT NULL, + message_id BIGINT NOT NULL, + message_payload MEDIUMBLOB NOT NULL, + message_encoding VARCHAR(16) NOT NULL, + PRIMARY KEY ( + queue_type, + queue_name, + queue_partition, + message_id + ) +); + +-- Stores information about Nexus endpoints +CREATE TABLE nexus_endpoints ( + id BINARY(16) NOT NULL, + data MEDIUMBLOB NOT NULL, -- temporal.server.api.persistence.v1.NexusEndpoint + data_encoding VARCHAR(16) NOT NULL, -- Encoding type used for serialization, in practice this should always be proto3 + version BIGINT NOT NULL, -- Version of this row, used for optimistic concurrency + PRIMARY KEY (id) +); + +-- Stores the version of Nexus endpoints table as a whole +CREATE TABLE nexus_endpoints_partition_status ( + id INT NOT NULL DEFAULT 0 CHECK (id = 0), -- Restrict the table to a single row since it will only be used for endpoints + version BIGINT NOT NULL, -- Version of the nexus_endpoints table + PRIMARY KEY (id) +); diff --git a/schema/starrocks/temporal/versioned/v1.0/manifest.json b/schema/starrocks/temporal/versioned/v1.0/manifest.json new file mode 100644 index 00000000000..698c16b092b --- /dev/null +++ b/schema/starrocks/temporal/versioned/v1.0/manifest.json @@ -0,0 +1,8 @@ +{ + "CurrVersion": "1.0", + "MinCompatibleVersion": "0.1", + "Description": "base version of schema", + "SchemaUpdateCqlFiles": [ + "schema.sql" + ] +} diff --git a/schema/starrocks/temporal/versioned/v1.0/schema.sql b/schema/starrocks/temporal/versioned/v1.0/schema.sql new file mode 100644 index 00000000000..84a1f8c2c6c --- /dev/null +++ b/schema/starrocks/temporal/versioned/v1.0/schema.sql @@ -0,0 +1,260 @@ +CREATE TABLE namespaces( + partition_id INT NOT NULL, + id BINARY(16) NOT NULL, + name VARCHAR(255) UNIQUE NOT NULL, + notification_version BIGINT NOT NULL, + -- + data BLOB NOT NULL, + data_encoding VARCHAR(16) NOT NULL, + is_global TINYINT(1) NOT NULL, + PRIMARY KEY(partition_id, id) +); + +CREATE TABLE namespace_metadata ( + partition_id INT NOT NULL, + notification_version BIGINT NOT NULL, + PRIMARY KEY(partition_id) +); + +INSERT INTO namespace_metadata (partition_id, notification_version) VALUES (54321, 1); + +CREATE TABLE shards ( + shard_id INT NOT NULL, + -- + range_id BIGINT NOT NULL, + data BLOB NOT NULL, + data_encoding VARCHAR(16) NOT NULL, + PRIMARY KEY (shard_id) +); + +CREATE TABLE transfer_tasks( + shard_id INT NOT NULL, + task_id BIGINT NOT NULL, + -- + data BLOB NOT NULL, + data_encoding VARCHAR(16) NOT NULL, + PRIMARY KEY (shard_id, task_id) +); + +CREATE TABLE executions( + shard_id INT NOT NULL, + namespace_id BINARY(16) NOT NULL, + workflow_id VARCHAR(255) NOT NULL, + run_id BINARY(16) NOT NULL, + -- + next_event_id BIGINT NOT NULL, + last_write_version BIGINT NOT NULL, + data BLOB NOT NULL, + data_encoding VARCHAR(16) NOT NULL, + state BLOB NOT NULL, + state_encoding VARCHAR(16) NOT NULL, + PRIMARY KEY (shard_id, namespace_id, workflow_id, run_id) +); + +CREATE TABLE current_executions( + shard_id INT NOT NULL, + namespace_id BINARY(16) NOT NULL, + workflow_id VARCHAR(255) NOT NULL, + -- + run_id BINARY(16) NOT NULL, + create_request_id VARCHAR(64) NOT NULL, + state INT NOT NULL, + status INT NOT NULL, + start_version BIGINT NOT NULL, + last_write_version BIGINT NOT NULL, + PRIMARY KEY (shard_id, namespace_id, workflow_id) +); + +CREATE TABLE buffered_events ( + shard_id INT NOT NULL, + namespace_id BINARY(16) NOT NULL, + workflow_id VARCHAR(255) NOT NULL, + run_id BINARY(16) NOT NULL, + id BIGINT AUTO_INCREMENT NOT NULL UNIQUE, + -- + data MEDIUMBLOB NOT NULL, + data_encoding VARCHAR(16) NOT NULL, + PRIMARY KEY (shard_id, namespace_id, workflow_id, run_id, id) +); + +CREATE TABLE tasks ( + range_hash INT UNSIGNED NOT NULL, + task_queue_id VARBINARY(272) NOT NULL, + task_id BIGINT NOT NULL, + -- + data BLOB NOT NULL, + data_encoding VARCHAR(16) NOT NULL, + PRIMARY KEY (range_hash, task_queue_id, task_id) +); + +CREATE TABLE task_queues ( + range_hash INT UNSIGNED NOT NULL, + task_queue_id VARBINARY(272) NOT NULL, + -- + range_id BIGINT NOT NULL, + data BLOB NOT NULL, + data_encoding VARCHAR(16) NOT NULL, + PRIMARY KEY (range_hash, task_queue_id) +); + +CREATE TABLE replication_tasks ( + shard_id INT NOT NULL, + task_id BIGINT NOT NULL, + -- + data BLOB NOT NULL, + data_encoding VARCHAR(16) NOT NULL, + PRIMARY KEY (shard_id, task_id) +); + +CREATE TABLE replication_tasks_dlq ( + source_cluster_name VARCHAR(255) NOT NULL, + shard_id INT NOT NULL, + task_id BIGINT NOT NULL, + -- + data BLOB NOT NULL, + data_encoding VARCHAR(16) NOT NULL, + PRIMARY KEY (source_cluster_name, shard_id, task_id) +); + +CREATE TABLE timer_tasks ( + shard_id INT NOT NULL, + visibility_timestamp DATETIME(6) NOT NULL, + task_id BIGINT NOT NULL, + -- + data BLOB NOT NULL, + data_encoding VARCHAR(16) NOT NULL, + PRIMARY KEY (shard_id, visibility_timestamp, task_id) +); + +CREATE TABLE activity_info_maps ( +-- each row corresponds to one key of one map + shard_id INT NOT NULL, + namespace_id BINARY(16) NOT NULL, + workflow_id VARCHAR(255) NOT NULL, + run_id BINARY(16) NOT NULL, + schedule_id BIGINT NOT NULL, +-- + data BLOB NOT NULL, + data_encoding VARCHAR(16), + PRIMARY KEY (shard_id, namespace_id, workflow_id, run_id, schedule_id) +); + +CREATE TABLE timer_info_maps ( + shard_id INT NOT NULL, + namespace_id BINARY(16) NOT NULL, + workflow_id VARCHAR(255) NOT NULL, + run_id BINARY(16) NOT NULL, + timer_id VARCHAR(255) NOT NULL, +-- + data BLOB NOT NULL, + data_encoding VARCHAR(16), + PRIMARY KEY (shard_id, namespace_id, workflow_id, run_id, timer_id) +); + +CREATE TABLE child_execution_info_maps ( + shard_id INT NOT NULL, + namespace_id BINARY(16) NOT NULL, + workflow_id VARCHAR(255) NOT NULL, + run_id BINARY(16) NOT NULL, + initiated_id BIGINT NOT NULL, +-- + data BLOB NOT NULL, + data_encoding VARCHAR(16), + PRIMARY KEY (shard_id, namespace_id, workflow_id, run_id, initiated_id) +); + +CREATE TABLE request_cancel_info_maps ( + shard_id INT NOT NULL, + namespace_id BINARY(16) NOT NULL, + workflow_id VARCHAR(255) NOT NULL, + run_id BINARY(16) NOT NULL, + initiated_id BIGINT NOT NULL, +-- + data BLOB NOT NULL, + data_encoding VARCHAR(16), + PRIMARY KEY (shard_id, namespace_id, workflow_id, run_id, initiated_id) +); + +CREATE TABLE signal_info_maps ( + shard_id INT NOT NULL, + namespace_id BINARY(16) NOT NULL, + workflow_id VARCHAR(255) NOT NULL, + run_id BINARY(16) NOT NULL, + initiated_id BIGINT NOT NULL, +-- + data BLOB NOT NULL, + data_encoding VARCHAR(16), + PRIMARY KEY (shard_id, namespace_id, workflow_id, run_id, initiated_id) +); + +CREATE TABLE signals_requested_sets ( + shard_id INT NOT NULL, + namespace_id BINARY(16) NOT NULL, + workflow_id VARCHAR(255) NOT NULL, + run_id BINARY(16) NOT NULL, + signal_id VARCHAR(64) NOT NULL, + -- + PRIMARY KEY (shard_id, namespace_id, workflow_id, run_id, signal_id) +); + +-- history eventsV2: history_node stores history event data +CREATE TABLE history_node ( + shard_id INT NOT NULL, + tree_id BINARY(16) NOT NULL, + branch_id BINARY(16) NOT NULL, + node_id BIGINT NOT NULL, + txn_id BIGINT NOT NULL, + -- + data MEDIUMBLOB NOT NULL, + data_encoding VARCHAR(16) NOT NULL, + PRIMARY KEY (shard_id, tree_id, branch_id, node_id, txn_id) +); + +-- history eventsV2: history_tree stores branch metadata +CREATE TABLE history_tree ( + shard_id INT NOT NULL, + tree_id BINARY(16) NOT NULL, + branch_id BINARY(16) NOT NULL, + -- + data BLOB NOT NULL, + data_encoding VARCHAR(16) NOT NULL, + PRIMARY KEY (shard_id, tree_id, branch_id) +); + +CREATE TABLE queue ( + queue_type INT NOT NULL, + message_id BIGINT NOT NULL, + message_payload BLOB NOT NULL, + PRIMARY KEY(queue_type, message_id) +); + +CREATE TABLE queue_metadata ( + queue_type INT NOT NULL, + data BLOB NOT NULL, + PRIMARY KEY(queue_type) +); + +CREATE TABLE cluster_metadata ( + metadata_partition INT NOT NULL, + immutable_data BLOB NOT NULL, + immutable_data_encoding VARCHAR(16) NOT NULL, + PRIMARY KEY(metadata_partition) +); + +CREATE TABLE cluster_membership +( + membership_partition INT NOT NULL, + host_id BINARY(16) NOT NULL, + rpc_address VARCHAR(15) NOT NULL, + rpc_port SMALLINT NOT NULL, + role TINYINT NOT NULL, + session_start TIMESTAMP DEFAULT '1970-01-02 00:00:01', + last_heartbeat TIMESTAMP DEFAULT '1970-01-02 00:00:01', + record_expiry TIMESTAMP DEFAULT '1970-01-02 00:00:01', + INDEX (role, host_id), + INDEX (role, last_heartbeat), + INDEX (rpc_address, role), + INDEX (last_heartbeat), + INDEX (record_expiry), + PRIMARY KEY (membership_partition, host_id) +); diff --git a/schema/starrocks/temporal/versioned/v1.1/cluster_metadata.sql b/schema/starrocks/temporal/versioned/v1.1/cluster_metadata.sql new file mode 100644 index 00000000000..36db5eb44c6 --- /dev/null +++ b/schema/starrocks/temporal/versioned/v1.1/cluster_metadata.sql @@ -0,0 +1,3 @@ +ALTER TABLE cluster_metadata ADD data BLOB NOT NULL; +ALTER TABLE cluster_metadata ADD data_encoding VARCHAR(16) NOT NULL DEFAULT 'Proto3'; +ALTER TABLE cluster_metadata ADD version BIGINT NOT NULL DEFAULT 1; \ No newline at end of file diff --git a/schema/starrocks/temporal/versioned/v1.1/manifest.json b/schema/starrocks/temporal/versioned/v1.1/manifest.json new file mode 100644 index 00000000000..ebcefd1c74e --- /dev/null +++ b/schema/starrocks/temporal/versioned/v1.1/manifest.json @@ -0,0 +1,8 @@ +{ + "CurrVersion": "1.1", + "MinCompatibleVersion": "1.0", + "Description": "schema update for cluster metadata", + "SchemaUpdateCqlFiles": [ + "cluster_metadata.sql" + ] +} diff --git a/schema/starrocks/temporal/versioned/v1.10/manifest.json b/schema/starrocks/temporal/versioned/v1.10/manifest.json new file mode 100644 index 00000000000..19d7098dfd9 --- /dev/null +++ b/schema/starrocks/temporal/versioned/v1.10/manifest.json @@ -0,0 +1,8 @@ +{ + "CurrVersion": "1.10", + "MinCompatibleVersion": "1.0", + "Description": "add storage for update records and create task_queue_user_data table", + "SchemaUpdateCqlFiles": [ + "task_queue_user_data.sql" + ] +} diff --git a/schema/starrocks/temporal/versioned/v1.10/task_queue_user_data.sql b/schema/starrocks/temporal/versioned/v1.10/task_queue_user_data.sql new file mode 100644 index 00000000000..45cd44c80fc --- /dev/null +++ b/schema/starrocks/temporal/versioned/v1.10/task_queue_user_data.sql @@ -0,0 +1,17 @@ +-- Stores task queue information such as user provided versioning data +CREATE TABLE task_queue_user_data ( + namespace_id BINARY(16) NOT NULL, + task_queue_name VARCHAR(255) NOT NULL, + data MEDIUMBLOB NOT NULL, -- temporal.server.api.persistence.v1.TaskQueueUserData + data_encoding VARCHAR(16) NOT NULL, -- Encoding type used for serialization, in practice this should always be proto3 + version BIGINT NOT NULL, -- Version of this row, used for optimistic concurrency + PRIMARY KEY (namespace_id, task_queue_name) +); + +-- Stores a mapping between build ids and task queues +CREATE TABLE build_id_to_task_queue ( + namespace_id BINARY(16) NOT NULL, + build_id VARCHAR(255) NOT NULL, + task_queue_name VARCHAR(255) NOT NULL, + PRIMARY KEY (namespace_id, build_id, task_queue_name) +); \ No newline at end of file diff --git a/schema/starrocks/temporal/versioned/v1.11/manifest.json b/schema/starrocks/temporal/versioned/v1.11/manifest.json new file mode 100644 index 00000000000..bfc1ef2ea72 --- /dev/null +++ b/schema/starrocks/temporal/versioned/v1.11/manifest.json @@ -0,0 +1,8 @@ +{ + "CurrVersion": "1.11", + "MinCompatibleVersion": "1.0", + "Description": "add queues and queue_messages tables", + "SchemaUpdateCqlFiles": [ + "queues.sql" + ] +} \ No newline at end of file diff --git a/schema/starrocks/temporal/versioned/v1.11/queues.sql b/schema/starrocks/temporal/versioned/v1.11/queues.sql new file mode 100644 index 00000000000..e68daa86acf --- /dev/null +++ b/schema/starrocks/temporal/versioned/v1.11/queues.sql @@ -0,0 +1,22 @@ +CREATE TABLE queues ( + queue_type INT NOT NULL, + queue_name VARCHAR(255) NOT NULL, + metadata_payload MEDIUMBLOB NOT NULL, + metadata_encoding VARCHAR(16) NOT NULL, + PRIMARY KEY (queue_type, queue_name) +); + +CREATE TABLE queue_messages ( + queue_type INT NOT NULL, + queue_name VARCHAR(255) NOT NULL, + queue_partition BIGINT NOT NULL, + message_id BIGINT NOT NULL, + message_payload MEDIUMBLOB NOT NULL, + message_encoding VARCHAR(16) NOT NULL, + PRIMARY KEY ( + queue_type, + queue_name, + queue_partition, + message_id + ) +); diff --git a/schema/starrocks/temporal/versioned/v1.12/manifest.json b/schema/starrocks/temporal/versioned/v1.12/manifest.json new file mode 100644 index 00000000000..8909ee5a6c9 --- /dev/null +++ b/schema/starrocks/temporal/versioned/v1.12/manifest.json @@ -0,0 +1,8 @@ +{ + "CurrVersion": "1.12", + "MinCompatibleVersion": "1.0", + "Description": "add storage for Nexus incoming service records and create nexus_incoming_services and nexus_incoming_services_partition_status tables", + "SchemaUpdateCqlFiles": [ + "nexus_incoming_services.sql" + ] +} diff --git a/schema/starrocks/temporal/versioned/v1.12/nexus_incoming_services.sql b/schema/starrocks/temporal/versioned/v1.12/nexus_incoming_services.sql new file mode 100644 index 00000000000..11d83dfdab5 --- /dev/null +++ b/schema/starrocks/temporal/versioned/v1.12/nexus_incoming_services.sql @@ -0,0 +1,15 @@ +-- Stores information about Nexus incoming services +CREATE TABLE nexus_incoming_services ( + service_id BINARY(16) NOT NULL, + data MEDIUMBLOB NOT NULL, -- temporal.server.api.persistence.v1.NexusIncomingService + data_encoding VARCHAR(16) NOT NULL, -- Encoding type used for serialization, in practice this should always be proto3 + version BIGINT NOT NULL, -- Version of this row, used for optimistic concurrency + PRIMARY KEY (service_id) +); + +-- Stores the version of Nexus incoming services table as a whole +CREATE TABLE nexus_incoming_services_partition_status ( + id INT NOT NULL DEFAULT 0 CHECK (id = 0), -- Restrict the table to a single row since it will only be used for incoming services + version BIGINT NOT NULL, -- Version of the nexus_incoming_services table + PRIMARY KEY (id) +); diff --git a/schema/starrocks/temporal/versioned/v1.13/manifest.json b/schema/starrocks/temporal/versioned/v1.13/manifest.json new file mode 100644 index 00000000000..49f04aceb73 --- /dev/null +++ b/schema/starrocks/temporal/versioned/v1.13/manifest.json @@ -0,0 +1,8 @@ +{ + "CurrVersion": "1.13", + "MinCompatibleVersion": "1.0", + "Description": "Replace nexus_incoming_services and nexus_incoming_services_partition_status tables with nexus_endpoints and nexus_endpoints_partition_status tables", + "SchemaUpdateCqlFiles": [ + "nexus_endpoints.sql" + ] +} diff --git a/schema/starrocks/temporal/versioned/v1.13/nexus_endpoints.sql b/schema/starrocks/temporal/versioned/v1.13/nexus_endpoints.sql new file mode 100644 index 00000000000..1de74c7696d --- /dev/null +++ b/schema/starrocks/temporal/versioned/v1.13/nexus_endpoints.sql @@ -0,0 +1,18 @@ +DROP TABLE nexus_incoming_services; +DROP TABLE nexus_incoming_services_partition_status; + +-- Stores information about Nexus endpoints +CREATE TABLE nexus_endpoints ( + id BINARY(16) NOT NULL, + data MEDIUMBLOB NOT NULL, -- temporal.server.api.persistence.v1.NexusEndpoint + data_encoding VARCHAR(16) NOT NULL, -- Encoding type used for serialization, in practice this should always be proto3 + version BIGINT NOT NULL, -- Version of this row, used for optimistic concurrency + PRIMARY KEY (id) +); + +-- Stores the version of Nexus endpoints table as a whole +CREATE TABLE nexus_endpoints_partition_status ( + id INT NOT NULL DEFAULT 0 CHECK (id = 0), -- Restrict the table to a single row since it will only be used for endpoints + version BIGINT NOT NULL, -- Version of the nexus_endpoints table + PRIMARY KEY (id) +); diff --git a/schema/starrocks/temporal/versioned/v1.14/add_current_executions_start_time.sql b/schema/starrocks/temporal/versioned/v1.14/add_current_executions_start_time.sql new file mode 100644 index 00000000000..5b1054283a8 --- /dev/null +++ b/schema/starrocks/temporal/versioned/v1.14/add_current_executions_start_time.sql @@ -0,0 +1 @@ +ALTER TABLE current_executions ADD COLUMN start_time DATETIME(6) NULL; \ No newline at end of file diff --git a/schema/starrocks/temporal/versioned/v1.14/manifest.json b/schema/starrocks/temporal/versioned/v1.14/manifest.json new file mode 100644 index 00000000000..1c53ba73cba --- /dev/null +++ b/schema/starrocks/temporal/versioned/v1.14/manifest.json @@ -0,0 +1,8 @@ +{ + "CurrVersion": "1.14", + "MinCompatibleVersion": "1.0", + "Description": "Add new start_time column", + "SchemaUpdateCqlFiles": [ + "add_current_executions_start_time.sql" + ] +} diff --git a/schema/starrocks/temporal/versioned/v1.15/add_current_executions_data.sql b/schema/starrocks/temporal/versioned/v1.15/add_current_executions_data.sql new file mode 100644 index 00000000000..b2780042572 --- /dev/null +++ b/schema/starrocks/temporal/versioned/v1.15/add_current_executions_data.sql @@ -0,0 +1,3 @@ +ALTER TABLE current_executions + ADD COLUMN data MEDIUMBLOB NULL, + ADD COLUMN data_encoding VARCHAR(16) NULL; diff --git a/schema/starrocks/temporal/versioned/v1.15/manifest.json b/schema/starrocks/temporal/versioned/v1.15/manifest.json new file mode 100644 index 00000000000..897b1cae107 --- /dev/null +++ b/schema/starrocks/temporal/versioned/v1.15/manifest.json @@ -0,0 +1,8 @@ +{ + "CurrVersion": "1.15", + "MinCompatibleVersion": "1.0", + "Description": "Add new column `data` to current_executions table", + "SchemaUpdateCqlFiles": [ + "add_current_executions_data.sql" + ] +} diff --git a/schema/starrocks/temporal/versioned/v1.16/fix_data_encoding_column.sql b/schema/starrocks/temporal/versioned/v1.16/fix_data_encoding_column.sql new file mode 100644 index 00000000000..a1716cac64a --- /dev/null +++ b/schema/starrocks/temporal/versioned/v1.16/fix_data_encoding_column.sql @@ -0,0 +1,2 @@ +ALTER TABLE current_executions DROP COLUMN data_encoding; +ALTER TABLE current_executions ADD COLUMN data_encoding VARCHAR(16) NOT NULL DEFAULT ''; diff --git a/schema/starrocks/temporal/versioned/v1.16/manifest.json b/schema/starrocks/temporal/versioned/v1.16/manifest.json new file mode 100644 index 00000000000..83317aa2b6a --- /dev/null +++ b/schema/starrocks/temporal/versioned/v1.16/manifest.json @@ -0,0 +1,8 @@ +{ + "CurrVersion": "1.16", + "MinCompatibleVersion": "1.0", + "Description": "Fix data_encoding column in current_executions table", + "SchemaUpdateCqlFiles": [ + "fix_data_encoding_column.sql" + ] +} diff --git a/schema/starrocks/temporal/versioned/v1.17/add_chasm_node_maps.sql b/schema/starrocks/temporal/versioned/v1.17/add_chasm_node_maps.sql new file mode 100644 index 00000000000..089374c4f6c --- /dev/null +++ b/schema/starrocks/temporal/versioned/v1.17/add_chasm_node_maps.sql @@ -0,0 +1,13 @@ +CREATE TABLE chasm_node_maps ( + shard_id INT NOT NULL, + namespace_id BINARY(16) NOT NULL, + workflow_id VARCHAR(255) NOT NULL, + run_id BINARY(16) NOT NULL, + chasm_path VARBINARY(1536) NOT NULL, +-- + metadata MEDIUMBLOB NOT NULL, + metadata_encoding VARCHAR(16), + data MEDIUMBLOB, + data_encoding VARCHAR(16), + PRIMARY KEY (shard_id, namespace_id, workflow_id, run_id, chasm_path) +); diff --git a/schema/starrocks/temporal/versioned/v1.17/manifest.json b/schema/starrocks/temporal/versioned/v1.17/manifest.json new file mode 100644 index 00000000000..b30639d5bf6 --- /dev/null +++ b/schema/starrocks/temporal/versioned/v1.17/manifest.json @@ -0,0 +1,8 @@ +{ + "CurrVersion": "1.17", + "MinCompatibleVersion": "1.0", + "Description": "Add new chasm_node_maps table", + "SchemaUpdateCqlFiles": [ + "add_chasm_node_maps.sql" + ] +} diff --git a/schema/starrocks/temporal/versioned/v1.18/manifest.json b/schema/starrocks/temporal/versioned/v1.18/manifest.json new file mode 100644 index 00000000000..05a87f73340 --- /dev/null +++ b/schema/starrocks/temporal/versioned/v1.18/manifest.json @@ -0,0 +1,8 @@ +{ + "CurrVersion": "1.18", + "MinCompatibleVersion": "1.0", + "Description": "Adds tasks_v2 table for fairness tasks", + "SchemaUpdateCqlFiles": [ + "tasks_v2.sql" + ] +} diff --git a/schema/starrocks/temporal/versioned/v1.18/tasks_v2.sql b/schema/starrocks/temporal/versioned/v1.18/tasks_v2.sql new file mode 100644 index 00000000000..36f9c637918 --- /dev/null +++ b/schema/starrocks/temporal/versioned/v1.18/tasks_v2.sql @@ -0,0 +1,23 @@ +-- Stores activity or workflow tasks +-- Used for fairness scheduling. (pass, task_id) are monotonically increasing. +CREATE TABLE tasks_v2 ( + range_hash INT UNSIGNED NOT NULL, + task_queue_id VARBINARY(272) NOT NULL, + pass BIGINT NOT NULL, -- pass for tasks (see stride scheduling algorithm for fairness) + task_id BIGINT NOT NULL, + -- + data MEDIUMBLOB NOT NULL, + data_encoding VARCHAR(16) NOT NULL, + PRIMARY KEY (range_hash, task_queue_id, pass, task_id) +); + +-- Stores ephemeral task queue information such as ack levels and expiry times +CREATE TABLE task_queues_v2 ( + range_hash INT UNSIGNED NOT NULL, + task_queue_id VARBINARY(272) NOT NULL, + -- + range_id BIGINT NOT NULL, + data MEDIUMBLOB NOT NULL, + data_encoding VARCHAR(16) NOT NULL, + PRIMARY KEY (range_hash, task_queue_id) +); diff --git a/schema/starrocks/temporal/versioned/v1.2/blob_size.sql b/schema/starrocks/temporal/versioned/v1.2/blob_size.sql new file mode 100644 index 00000000000..51d3fcebee4 --- /dev/null +++ b/schema/starrocks/temporal/versioned/v1.2/blob_size.sql @@ -0,0 +1,20 @@ +ALTER TABLE namespaces MODIFY COLUMN data MEDIUMBLOB; +ALTER TABLE shards MODIFY COLUMN data MEDIUMBLOB; +ALTER TABLE transfer_tasks MODIFY COLUMN data MEDIUMBLOB; +ALTER TABLE executions MODIFY COLUMN data MEDIUMBLOB; +ALTER TABLE executions MODIFY COLUMN state MEDIUMBLOB; +ALTER TABLE tasks MODIFY COLUMN data MEDIUMBLOB; +ALTER TABLE task_queues MODIFY COLUMN data MEDIUMBLOB; +ALTER TABLE replication_tasks MODIFY COLUMN data MEDIUMBLOB; +ALTER TABLE replication_tasks_dlq MODIFY COLUMN data MEDIUMBLOB; +ALTER TABLE timer_tasks MODIFY COLUMN data MEDIUMBLOB; +ALTER TABLE activity_info_maps MODIFY COLUMN data MEDIUMBLOB; +ALTER TABLE timer_info_maps MODIFY COLUMN data MEDIUMBLOB; +ALTER TABLE child_execution_info_maps MODIFY COLUMN data MEDIUMBLOB; +ALTER TABLE request_cancel_info_maps MODIFY COLUMN data MEDIUMBLOB; +ALTER TABLE signal_info_maps MODIFY COLUMN data MEDIUMBLOB; +ALTER TABLE history_tree MODIFY COLUMN data MEDIUMBLOB; +ALTER TABLE queue MODIFY COLUMN message_payload MEDIUMBLOB; +ALTER TABLE queue_metadata MODIFY COLUMN data MEDIUMBLOB; +ALTER TABLE cluster_metadata MODIFY COLUMN data MEDIUMBLOB; +ALTER TABLE cluster_metadata MODIFY COLUMN immutable_data MEDIUMBLOB; diff --git a/schema/starrocks/temporal/versioned/v1.2/manifest.json b/schema/starrocks/temporal/versioned/v1.2/manifest.json new file mode 100644 index 00000000000..d25c966894a --- /dev/null +++ b/schema/starrocks/temporal/versioned/v1.2/manifest.json @@ -0,0 +1,9 @@ +{ + "CurrVersion": "1.2", + "MinCompatibleVersion": "1.0", + "Description": "schema update for RPC replication and blob size adjustments", + "SchemaUpdateCqlFiles": [ + "queue.sql", + "blob_size.sql" + ] +} diff --git a/schema/starrocks/temporal/versioned/v1.2/queue.sql b/schema/starrocks/temporal/versioned/v1.2/queue.sql new file mode 100644 index 00000000000..e3f1587fbb0 --- /dev/null +++ b/schema/starrocks/temporal/versioned/v1.2/queue.sql @@ -0,0 +1,2 @@ +ALTER TABLE queue ADD message_encoding VARCHAR(16) NOT NULL DEFAULT 'Json'; +ALTER TABLE queue_metadata ADD data_encoding VARCHAR(16) NOT NULL DEFAULT 'Json'; diff --git a/schema/starrocks/temporal/versioned/v1.3/manifest.json b/schema/starrocks/temporal/versioned/v1.3/manifest.json new file mode 100644 index 00000000000..bf9e4fd3f89 --- /dev/null +++ b/schema/starrocks/temporal/versioned/v1.3/manifest.json @@ -0,0 +1,8 @@ +{ + "CurrVersion": "1.3", + "MinCompatibleVersion": "1.0", + "Description": "schema update for kafka deprecation", + "SchemaUpdateCqlFiles": [ + "visibility_tasks.sql" + ] +} \ No newline at end of file diff --git a/schema/starrocks/temporal/versioned/v1.3/visibility_tasks.sql b/schema/starrocks/temporal/versioned/v1.3/visibility_tasks.sql new file mode 100644 index 00000000000..b8ebcdd696b --- /dev/null +++ b/schema/starrocks/temporal/versioned/v1.3/visibility_tasks.sql @@ -0,0 +1,8 @@ +CREATE TABLE visibility_tasks( + shard_id INT NOT NULL, + task_id BIGINT NOT NULL, + -- + data MEDIUMBLOB NOT NULL, + data_encoding VARCHAR(16) NOT NULL, + PRIMARY KEY (shard_id, task_id) +); \ No newline at end of file diff --git a/schema/starrocks/temporal/versioned/v1.4/cluster_metadata.sql b/schema/starrocks/temporal/versioned/v1.4/cluster_metadata.sql new file mode 100644 index 00000000000..b909e3a8cfa --- /dev/null +++ b/schema/starrocks/temporal/versioned/v1.4/cluster_metadata.sql @@ -0,0 +1,2 @@ +ALTER TABLE cluster_metadata DROP immutable_data; +ALTER TABLE cluster_metadata DROP immutable_data_encoding; diff --git a/schema/starrocks/temporal/versioned/v1.4/manifest.json b/schema/starrocks/temporal/versioned/v1.4/manifest.json new file mode 100644 index 00000000000..3f2a8f4c07f --- /dev/null +++ b/schema/starrocks/temporal/versioned/v1.4/manifest.json @@ -0,0 +1,8 @@ +{ + "CurrVersion": "1.4", + "MinCompatibleVersion": "1.0", + "Description": "schema update for cluster metadata cleanup", + "SchemaUpdateCqlFiles": [ + "cluster_metadata.sql" + ] +} diff --git a/schema/starrocks/temporal/versioned/v1.5/cluster_membership.sql b/schema/starrocks/temporal/versioned/v1.5/cluster_membership.sql new file mode 100644 index 00000000000..04485b82cf0 --- /dev/null +++ b/schema/starrocks/temporal/versioned/v1.5/cluster_membership.sql @@ -0,0 +1 @@ +ALTER TABLE cluster_membership MODIFY COLUMN rpc_address VARCHAR(128); diff --git a/schema/starrocks/temporal/versioned/v1.5/event.sql b/schema/starrocks/temporal/versioned/v1.5/event.sql new file mode 100644 index 00000000000..6437b811b76 --- /dev/null +++ b/schema/starrocks/temporal/versioned/v1.5/event.sql @@ -0,0 +1 @@ +ALTER TABLE history_node ADD prev_txn_id BIGINT NOT NULL DEFAULT 0; diff --git a/schema/starrocks/temporal/versioned/v1.5/executions.sql b/schema/starrocks/temporal/versioned/v1.5/executions.sql new file mode 100644 index 00000000000..dbdd9e52af7 --- /dev/null +++ b/schema/starrocks/temporal/versioned/v1.5/executions.sql @@ -0,0 +1 @@ +ALTER TABLE executions ADD db_record_version BIGINT NOT NULL DEFAULT 0; diff --git a/schema/starrocks/temporal/versioned/v1.5/manifest.json b/schema/starrocks/temporal/versioned/v1.5/manifest.json new file mode 100644 index 00000000000..56fc8d59f2e --- /dev/null +++ b/schema/starrocks/temporal/versioned/v1.5/manifest.json @@ -0,0 +1,10 @@ +{ + "CurrVersion": "1.5", + "MinCompatibleVersion": "1.0", + "Description": "schema update for cluster_membership, executions and history_node tables", + "SchemaUpdateCqlFiles": [ + "event.sql", + "executions.sql", + "cluster_membership.sql" + ] +} diff --git a/schema/starrocks/temporal/versioned/v1.6/manifest.json b/schema/starrocks/temporal/versioned/v1.6/manifest.json new file mode 100644 index 00000000000..bbd66684b2e --- /dev/null +++ b/schema/starrocks/temporal/versioned/v1.6/manifest.json @@ -0,0 +1,8 @@ +{ + "CurrVersion": "1.6", + "MinCompatibleVersion": "1.0", + "Description": "schema update for queue_metadata", + "SchemaUpdateCqlFiles": [ + "queue_metadata.sql" + ] +} diff --git a/schema/starrocks/temporal/versioned/v1.6/queue_metadata.sql b/schema/starrocks/temporal/versioned/v1.6/queue_metadata.sql new file mode 100644 index 00000000000..33830d21b0d --- /dev/null +++ b/schema/starrocks/temporal/versioned/v1.6/queue_metadata.sql @@ -0,0 +1 @@ +ALTER TABLE queue_metadata ADD version BIGINT NOT NULL DEFAULT 0; diff --git a/schema/starrocks/temporal/versioned/v1.7/cluster_metadata_info.sql b/schema/starrocks/temporal/versioned/v1.7/cluster_metadata_info.sql new file mode 100644 index 00000000000..e7141a7ee48 --- /dev/null +++ b/schema/starrocks/temporal/versioned/v1.7/cluster_metadata_info.sql @@ -0,0 +1,8 @@ +CREATE TABLE cluster_metadata_info ( + metadata_partition INT NOT NULL, + cluster_name VARCHAR(255) NOT NULL, + data MEDIUMBLOB NOT NULL, + data_encoding VARCHAR(16) NOT NULL, + version BIGINT NOT NULL, + PRIMARY KEY(metadata_partition, cluster_name) +); \ No newline at end of file diff --git a/schema/starrocks/temporal/versioned/v1.7/manifest.json b/schema/starrocks/temporal/versioned/v1.7/manifest.json new file mode 100644 index 00000000000..5d99bfe1134 --- /dev/null +++ b/schema/starrocks/temporal/versioned/v1.7/manifest.json @@ -0,0 +1,10 @@ +{ + "CurrVersion": "1.7", + "MinCompatibleVersion": "1.0", + "Description": "create cluster metadata info table to store cluster information and executions to store tiered storage queue", + "SchemaUpdateCqlFiles": [ + "cluster_metadata_info.sql", + "no_start_version.sql", + "tiered_storage_tasks.sql" + ] +} diff --git a/schema/starrocks/temporal/versioned/v1.7/no_start_version.sql b/schema/starrocks/temporal/versioned/v1.7/no_start_version.sql new file mode 100644 index 00000000000..d58adf0c319 --- /dev/null +++ b/schema/starrocks/temporal/versioned/v1.7/no_start_version.sql @@ -0,0 +1 @@ +ALTER TABLE current_executions ALTER COLUMN start_version SET DEFAULT 0; \ No newline at end of file diff --git a/schema/starrocks/temporal/versioned/v1.7/tiered_storage_tasks.sql b/schema/starrocks/temporal/versioned/v1.7/tiered_storage_tasks.sql new file mode 100644 index 00000000000..8f9dc7b461f --- /dev/null +++ b/schema/starrocks/temporal/versioned/v1.7/tiered_storage_tasks.sql @@ -0,0 +1,8 @@ +CREATE TABLE tiered_storage_tasks ( + shard_id INT NOT NULL, + task_id BIGINT NOT NULL, + -- + data MEDIUMBLOB NOT NULL, + data_encoding VARCHAR(16) NOT NULL, + PRIMARY KEY (shard_id, task_id) +); \ No newline at end of file diff --git a/schema/starrocks/temporal/versioned/v1.8/alter_columns.sql b/schema/starrocks/temporal/versioned/v1.8/alter_columns.sql new file mode 100644 index 00000000000..47943f1b550 --- /dev/null +++ b/schema/starrocks/temporal/versioned/v1.8/alter_columns.sql @@ -0,0 +1,2 @@ +ALTER TABLE current_executions MODIFY COLUMN create_request_id VARCHAR(255); +ALTER TABLE signals_requested_sets MODIFY COLUMN signal_id VARCHAR(255); diff --git a/schema/starrocks/temporal/versioned/v1.8/drop_unused_tasks_table.sql b/schema/starrocks/temporal/versioned/v1.8/drop_unused_tasks_table.sql new file mode 100644 index 00000000000..b4b35b2ce5e --- /dev/null +++ b/schema/starrocks/temporal/versioned/v1.8/drop_unused_tasks_table.sql @@ -0,0 +1 @@ +DROP TABLE tiered_storage_tasks; \ No newline at end of file diff --git a/schema/starrocks/temporal/versioned/v1.8/manifest.json b/schema/starrocks/temporal/versioned/v1.8/manifest.json new file mode 100644 index 00000000000..d49fed323fc --- /dev/null +++ b/schema/starrocks/temporal/versioned/v1.8/manifest.json @@ -0,0 +1,9 @@ +{ + "CurrVersion": "1.8", + "MinCompatibleVersion": "1.0", + "Description": "drop unused tasks table; expand VARCHAR columns governed by maxIDLength to VARCHAR(255)", + "SchemaUpdateCqlFiles": [ + "drop_unused_tasks_table.sql", + "alter_columns.sql" + ] +} diff --git a/schema/starrocks/temporal/versioned/v1.9/history_tasks_table.sql b/schema/starrocks/temporal/versioned/v1.9/history_tasks_table.sql new file mode 100644 index 00000000000..6c7cd15480c --- /dev/null +++ b/schema/starrocks/temporal/versioned/v1.9/history_tasks_table.sql @@ -0,0 +1,20 @@ +CREATE TABLE history_immediate_tasks( + shard_id INT NOT NULL, + category_id INT NOT NULL, + task_id BIGINT NOT NULL, + -- + data MEDIUMBLOB NOT NULL, + data_encoding VARCHAR(16) NOT NULL, + PRIMARY KEY (shard_id, category_id, task_id) +); + +CREATE TABLE history_scheduled_tasks ( + shard_id INT NOT NULL, + category_id INT NOT NULL, + visibility_timestamp DATETIME(6) NOT NULL, + task_id BIGINT NOT NULL, + -- + data MEDIUMBLOB NOT NULL, + data_encoding VARCHAR(16) NOT NULL, + PRIMARY KEY (shard_id, category_id, visibility_timestamp, task_id) +); \ No newline at end of file diff --git a/schema/starrocks/temporal/versioned/v1.9/manifest.json b/schema/starrocks/temporal/versioned/v1.9/manifest.json new file mode 100644 index 00000000000..9df45be3080 --- /dev/null +++ b/schema/starrocks/temporal/versioned/v1.9/manifest.json @@ -0,0 +1,8 @@ +{ + "CurrVersion": "1.9", + "MinCompatibleVersion": "1.0", + "Description": "add history tasks table", + "SchemaUpdateCqlFiles": [ + "history_tasks_table.sql" + ] +} diff --git a/schema/starrocks/version.go b/schema/starrocks/version.go new file mode 100644 index 00000000000..90bf3cc655a --- /dev/null +++ b/schema/starrocks/version.go @@ -0,0 +1,109 @@ +// The MIT License +// +// Copyright (c) 2025 Temporal Technologies Inc. All rights reserved. +// +// Copyright (c) 2020 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +// The MIT License +// +// Copyright (c) 2025 Temporal Technologies Inc. All rights reserved. +// +// Copyright (c) 2020 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +package starrocks + +import ( + "github.com/jmoiron/sqlx" + "go.temporal.io/server/common/clock" + "go.temporal.io/server/common/config" + "go.temporal.io/server/common/log" + "go.temporal.io/server/common/metrics" + "go.temporal.io/server/common/persistence/sql" + "go.temporal.io/server/common/persistence/sql/sqlplugin" + "go.temporal.io/server/common/persistence/sql/sqlplugin/starrocks/session" + "go.temporal.io/server/common/resolver" +) + +const ( + // PluginName is the name of the plugin + PluginName = "starrocks" +) + +type plugin struct{} + +var _ sqlplugin.Plugin = (*plugin)(nil) + +func init() { + sql.RegisterPlugin(PluginName, &plugin{}) +} + +// CreateDB initialize the db object +func (p *plugin) CreateDB( + dbKind sqlplugin.DbKind, + cfg *config.SQL, + r resolver.ServiceResolver, + logger log.Logger, + metricsHandler metrics.Handler, +) (sqlplugin.GenericDB, error) { + connect := func() (*sqlx.DB, error) { + if cfg.Connect != nil { + return cfg.Connect(cfg) + } + return p.createDBConnection(dbKind, cfg, r) + } + handle := sqlplugin.NewDatabaseHandle(dbKind, connect, isConnNeedsRefreshError, logger, metricsHandler, clock.NewRealTimeSource()) + db := newDB(dbKind, cfg.DatabaseName, handle, nil) + return db, nil +} + +// CreateDBConnection creates a returns a reference to a logical connection to the +// underlying SQL database. The returned object is to tied to a single +// SQL database and the object can be used to perform CRUD operations on +// the tables in the database +func (p *plugin) createDBConnection( + dbKind sqlplugin.DbKind, + cfg *config.SQL, + resolver resolver.ServiceResolver, +) (*sqlx.DB, error) { + starrocksSession, err := session.NewSession(dbKind, cfg, resolver) + if err != nil { + return nil, err + } + return starrocksSession.DB, nil +} \ No newline at end of file diff --git a/schema/starrocks/visibility/database.sql b/schema/starrocks/visibility/database.sql new file mode 100644 index 00000000000..4cb0a650d0e --- /dev/null +++ b/schema/starrocks/visibility/database.sql @@ -0,0 +1 @@ +CREATE DATABASE temporal_visibility CHARACTER SET utf8mb4; diff --git a/schema/starrocks/visibility/schema.sql b/schema/starrocks/visibility/schema.sql new file mode 100644 index 00000000000..7cb6aa0897c --- /dev/null +++ b/schema/starrocks/visibility/schema.sql @@ -0,0 +1,168 @@ +CREATE TABLE executions_visibility ( + namespace_id CHAR(64) NOT NULL, + run_id CHAR(64) NOT NULL, + _version BIGINT NOT NULL DEFAULT 0, -- increasing version, used to reject upserts which are out of order + start_time DATETIME(6) NOT NULL, + execution_time DATETIME(6) NOT NULL, + workflow_id VARCHAR(255) NOT NULL, + workflow_type_name VARCHAR(255) NOT NULL, + status INT NOT NULL, -- enum WorkflowExecutionStatus {RUNNING, COMPLETED, FAILED, CANCELED, TERMINATED, CONTINUED_AS_NEW, TIMED_OUT} + close_time DATETIME(6) NULL, + history_length BIGINT NULL, + history_size_bytes BIGINT NULL, + execution_duration BIGINT NULL, + state_transition_count BIGINT NULL, + memo BLOB NULL, + encoding VARCHAR(64) NOT NULL, + task_queue VARCHAR(255) NOT NULL DEFAULT '', + search_attributes JSON NULL, + parent_workflow_id VARCHAR(255) NULL, + parent_run_id VARCHAR(255) NULL, + root_workflow_id VARCHAR(255) NOT NULL DEFAULT '', + root_run_id VARCHAR(255) NOT NULL DEFAULT '', + + -- Each search attribute has its own generated column. + -- For string types (keyword and text), we need to unquote the json string, + -- ie., use `->>` instead of `->` operator. + -- For text types, the generated column need to be STORED instead of VIRTUAL, + -- so we can create a full-text search index. + -- For datetime type, MySQL can't cast datetime string with timezone to + -- datetime type directly, so we need to call CONVERT_TZ to convert to UTC. + -- Check the `custom_search_attributes` table for complete set of examples. + + -- Predefined search attributes + TemporalChangeVersion JSON GENERATED ALWAYS AS (search_attributes->"$.TemporalChangeVersion"), + BinaryChecksums JSON GENERATED ALWAYS AS (search_attributes->"$.BinaryChecksums"), + BatcherUser VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>"$.BatcherUser"), + TemporalScheduledStartTime DATETIME(6) GENERATED ALWAYS AS ( + CONVERT_TZ( + REGEXP_REPLACE(search_attributes->>"$.TemporalScheduledStartTime", 'Z|[+-][0-9]{2}:[0-9]{2}$', ''), + SUBSTR(REPLACE(search_attributes->>"$.TemporalScheduledStartTime", 'Z', '+00:00'), -6, 6), + '+00:00' + ) + ), + TemporalScheduledById VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>"$.TemporalScheduledById"), + TemporalSchedulePaused BOOLEAN GENERATED ALWAYS AS (search_attributes->"$.TemporalSchedulePaused"), + TemporalNamespaceDivision VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>"$.TemporalNamespaceDivision"), + BuildIds JSON GENERATED ALWAYS AS (search_attributes->"$.BuildIds"), + TemporalPauseInfo JSON GENERATED ALWAYS AS (search_attributes->"$.TemporalPauseInfo"), + TemporalWorkerDeploymentVersion VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>"$.TemporalWorkerDeploymentVersion"), + TemporalWorkflowVersioningBehavior VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>"$.TemporalWorkflowVersioningBehavior"), + TemporalWorkerDeployment VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>"$.TemporalWorkerDeployment"), + + PRIMARY KEY (namespace_id, run_id) +); + +CREATE INDEX default_idx ON executions_visibility (namespace_id, (COALESCE(close_time, CAST('9999-12-31 23:59:59' AS DATETIME))) DESC, start_time DESC, run_id); +CREATE INDEX by_execution_time ON executions_visibility (namespace_id, execution_time, (COALESCE(close_time, CAST('9999-12-31 23:59:59' AS DATETIME))) DESC, start_time DESC, run_id); +CREATE INDEX by_workflow_id ON executions_visibility (namespace_id, workflow_id, (COALESCE(close_time, CAST('9999-12-31 23:59:59' AS DATETIME))) DESC, start_time DESC, run_id); +CREATE INDEX by_workflow_type ON executions_visibility (namespace_id, workflow_type_name, (COALESCE(close_time, CAST('9999-12-31 23:59:59' AS DATETIME))) DESC, start_time DESC, run_id); +CREATE INDEX by_status ON executions_visibility (namespace_id, status, (COALESCE(close_time, CAST('9999-12-31 23:59:59' AS DATETIME))) DESC, start_time DESC, run_id); +CREATE INDEX by_history_length ON executions_visibility (namespace_id, history_length, (COALESCE(close_time, CAST('9999-12-31 23:59:59' AS DATETIME))) DESC, start_time DESC, run_id); +CREATE INDEX by_history_size_bytes ON executions_visibility (namespace_id, history_size_bytes, (COALESCE(close_time, CAST('9999-12-31 23:59:59' AS DATETIME))) DESC, start_time DESC, run_id); +CREATE INDEX by_execution_duration ON executions_visibility (namespace_id, execution_duration, (COALESCE(close_time, CAST('9999-12-31 23:59:59' AS DATETIME))) DESC, start_time DESC, run_id); +CREATE INDEX by_state_transition_count ON executions_visibility (namespace_id, state_transition_count, (COALESCE(close_time, CAST('9999-12-31 23:59:59' AS DATETIME))) DESC, start_time DESC, run_id); +CREATE INDEX by_task_queue ON executions_visibility (namespace_id, task_queue, (COALESCE(close_time, CAST('9999-12-31 23:59:59' AS DATETIME))) DESC, start_time DESC, run_id); +CREATE INDEX by_parent_workflow_id ON executions_visibility (namespace_id, parent_workflow_id, (COALESCE(close_time, CAST('9999-12-31 23:59:59' AS DATETIME))) DESC, start_time DESC, run_id); +CREATE INDEX by_parent_run_id ON executions_visibility (namespace_id, parent_run_id, (COALESCE(close_time, CAST('9999-12-31 23:59:59' AS DATETIME))) DESC, start_time DESC, run_id); +CREATE INDEX by_root_workflow_id ON executions_visibility (namespace_id, root_workflow_id, (COALESCE(close_time, CAST('9999-12-31 23:59:59' AS DATETIME))) DESC, start_time DESC, run_id); +CREATE INDEX by_root_run_id ON executions_visibility (namespace_id, root_run_id, (COALESCE(close_time, CAST('9999-12-31 23:59:59' AS DATETIME))) DESC, start_time DESC, run_id); + +-- Indexes for the predefined search attributes +CREATE INDEX by_temporal_change_version ON executions_visibility (namespace_id, (CAST(TemporalChangeVersion AS CHAR(255) ARRAY)), (COALESCE(close_time, CAST('9999-12-31 23:59:59' AS DATETIME))) DESC, start_time DESC, run_id); +CREATE INDEX by_binary_checksums ON executions_visibility (namespace_id, (CAST(BinaryChecksums AS CHAR(255) ARRAY)), (COALESCE(close_time, CAST('9999-12-31 23:59:59' AS DATETIME))) DESC, start_time DESC, run_id); +CREATE INDEX by_build_ids ON executions_visibility (namespace_id, (CAST(BuildIds AS CHAR(255) ARRAY)), (COALESCE(close_time, CAST('9999-12-31 23:59:59' AS DATETIME))) DESC, start_time DESC, run_id); +CREATE INDEX by_temporal_pause_info ON executions_visibility (namespace_id, (CAST(TemporalPauseInfo AS CHAR(255) ARRAY)), (COALESCE(close_time, CAST('9999-12-31 23:59:59' AS DATETIME))) DESC, start_time DESC, run_id); +CREATE INDEX by_temporal_worker_deployment_version ON executions_visibility (namespace_id, TemporalWorkerDeploymentVersion, (COALESCE(close_time, CAST('9999-12-31 23:59:59' AS DATETIME))) DESC, start_time DESC, run_id); +CREATE INDEX by_temporal_workflow_versioning_behavior ON executions_visibility (namespace_id, TemporalWorkflowVersioningBehavior, (COALESCE(close_time, CAST('9999-12-31 23:59:59' AS DATETIME))) DESC, start_time DESC, run_id); +CREATE INDEX by_temporal_worker_deployment ON executions_visibility (namespace_id, TemporalWorkerDeployment, (COALESCE(close_time, CAST('9999-12-31 23:59:59' AS DATETIME))) DESC, start_time DESC, run_id); +CREATE INDEX by_batcher_user ON executions_visibility (namespace_id, BatcherUser, (COALESCE(close_time, CAST('9999-12-31 23:59:59' AS DATETIME))) DESC, start_time DESC, run_id); +CREATE INDEX by_temporal_scheduled_start_time ON executions_visibility (namespace_id, TemporalScheduledStartTime, (COALESCE(close_time, CAST('9999-12-31 23:59:59' AS DATETIME))) DESC, start_time DESC, run_id); +CREATE INDEX by_temporal_scheduled_by_id ON executions_visibility (namespace_id, TemporalScheduledById, (COALESCE(close_time, CAST('9999-12-31 23:59:59' AS DATETIME))) DESC, start_time DESC, run_id); +CREATE INDEX by_temporal_schedule_paused ON executions_visibility (namespace_id, TemporalSchedulePaused, (COALESCE(close_time, CAST('9999-12-31 23:59:59' AS DATETIME))) DESC, start_time DESC, run_id); +CREATE INDEX by_temporal_namespace_division ON executions_visibility (namespace_id, TemporalNamespaceDivision, (COALESCE(close_time, CAST('9999-12-31 23:59:59' AS DATETIME))) DESC, start_time DESC, run_id); + + +CREATE TABLE custom_search_attributes ( + namespace_id CHAR(64) NOT NULL, + run_id CHAR(64) NOT NULL, + _version BIGINT NOT NULL DEFAULT 0, + search_attributes JSON NULL, + Bool01 BOOLEAN GENERATED ALWAYS AS (search_attributes->"$.Bool01"), + Bool02 BOOLEAN GENERATED ALWAYS AS (search_attributes->"$.Bool02"), + Bool03 BOOLEAN GENERATED ALWAYS AS (search_attributes->"$.Bool03"), + Datetime01 DATETIME(6) GENERATED ALWAYS AS ( + CONVERT_TZ( + REGEXP_REPLACE(search_attributes->>"$.Datetime01", 'Z|[+-][0-9]{2}:[0-9]{2}$', ''), + SUBSTR(REPLACE(search_attributes->>"$.Datetime01", 'Z', '+00:00'), -6, 6), + '+00:00' + ) + ), + Datetime02 DATETIME(6) GENERATED ALWAYS AS ( + CONVERT_TZ( + REGEXP_REPLACE(search_attributes->>"$.Datetime02", 'Z|[+-][0-9]{2}:[0-9]{2}$', ''), + SUBSTR(REPLACE(search_attributes->>"$.Datetime02", 'Z', '+00:00'), -6, 6), + '+00:00' + ) + ), + Datetime03 DATETIME(6) GENERATED ALWAYS AS ( + CONVERT_TZ( + REGEXP_REPLACE(search_attributes->>"$.Datetime03", 'Z|[+-][0-9]{2}:[0-9]{2}$', ''), + SUBSTR(REPLACE(search_attributes->>"$.Datetime03", 'Z', '+00:00'), -6, 6), + '+00:00' + ) + ), + Double01 DECIMAL(20, 5) GENERATED ALWAYS AS (search_attributes->"$.Double01"), + Double02 DECIMAL(20, 5) GENERATED ALWAYS AS (search_attributes->"$.Double02"), + Double03 DECIMAL(20, 5) GENERATED ALWAYS AS (search_attributes->"$.Double03"), + Int01 BIGINT GENERATED ALWAYS AS (search_attributes->"$.Int01"), + Int02 BIGINT GENERATED ALWAYS AS (search_attributes->"$.Int02"), + Int03 BIGINT GENERATED ALWAYS AS (search_attributes->"$.Int03"), + Keyword01 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>"$.Keyword01"), + Keyword02 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>"$.Keyword02"), + Keyword03 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>"$.Keyword03"), + Keyword04 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>"$.Keyword04"), + Keyword05 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>"$.Keyword05"), + Keyword06 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>"$.Keyword06"), + Keyword07 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>"$.Keyword07"), + Keyword08 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>"$.Keyword08"), + Keyword09 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>"$.Keyword09"), + Keyword10 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>"$.Keyword10"), + Text01 TEXT GENERATED ALWAYS AS (search_attributes->>"$.Text01") STORED, + Text02 TEXT GENERATED ALWAYS AS (search_attributes->>"$.Text02") STORED, + Text03 TEXT GENERATED ALWAYS AS (search_attributes->>"$.Text03") STORED, + KeywordList01 JSON GENERATED ALWAYS AS (search_attributes->"$.KeywordList01"), + KeywordList02 JSON GENERATED ALWAYS AS (search_attributes->"$.KeywordList02"), + KeywordList03 JSON GENERATED ALWAYS AS (search_attributes->"$.KeywordList03"), + + PRIMARY KEY (namespace_id, run_id) +); + +CREATE INDEX by_bool_01 ON custom_search_attributes (namespace_id, Bool01); +CREATE INDEX by_bool_02 ON custom_search_attributes (namespace_id, Bool02); +CREATE INDEX by_bool_03 ON custom_search_attributes (namespace_id, Bool03); +CREATE INDEX by_datetime_01 ON custom_search_attributes (namespace_id, Datetime01); +CREATE INDEX by_datetime_02 ON custom_search_attributes (namespace_id, Datetime02); +CREATE INDEX by_datetime_03 ON custom_search_attributes (namespace_id, Datetime03); +CREATE INDEX by_double_01 ON custom_search_attributes (namespace_id, Double01); +CREATE INDEX by_double_02 ON custom_search_attributes (namespace_id, Double02); +CREATE INDEX by_double_03 ON custom_search_attributes (namespace_id, Double03); +CREATE INDEX by_int_01 ON custom_search_attributes (namespace_id, Int01); +CREATE INDEX by_int_02 ON custom_search_attributes (namespace_id, Int02); +CREATE INDEX by_int_03 ON custom_search_attributes (namespace_id, Int03); +CREATE INDEX by_keyword_01 ON custom_search_attributes (namespace_id, Keyword01); +CREATE INDEX by_keyword_02 ON custom_search_attributes (namespace_id, Keyword02); +CREATE INDEX by_keyword_03 ON custom_search_attributes (namespace_id, Keyword03); +CREATE INDEX by_keyword_04 ON custom_search_attributes (namespace_id, Keyword04); +CREATE INDEX by_keyword_05 ON custom_search_attributes (namespace_id, Keyword05); +CREATE INDEX by_keyword_06 ON custom_search_attributes (namespace_id, Keyword06); +CREATE INDEX by_keyword_07 ON custom_search_attributes (namespace_id, Keyword07); +CREATE INDEX by_keyword_08 ON custom_search_attributes (namespace_id, Keyword08); +CREATE INDEX by_keyword_09 ON custom_search_attributes (namespace_id, Keyword09); +CREATE INDEX by_keyword_10 ON custom_search_attributes (namespace_id, Keyword10); +CREATE FULLTEXT INDEX by_text_01 ON custom_search_attributes (Text01); +CREATE FULLTEXT INDEX by_text_02 ON custom_search_attributes (Text02); +CREATE FULLTEXT INDEX by_text_03 ON custom_search_attributes (Text03); +CREATE INDEX by_keyword_list_01 ON custom_search_attributes (namespace_id, (CAST(KeywordList01 AS CHAR(255) ARRAY))); +CREATE INDEX by_keyword_list_02 ON custom_search_attributes (namespace_id, (CAST(KeywordList02 AS CHAR(255) ARRAY))); +CREATE INDEX by_keyword_list_03 ON custom_search_attributes (namespace_id, (CAST(KeywordList03 AS CHAR(255) ARRAY))); diff --git a/schema/starrocks/visibility/versioned/v1.0/manifest.json b/schema/starrocks/visibility/versioned/v1.0/manifest.json new file mode 100644 index 00000000000..a1ce2f782bd --- /dev/null +++ b/schema/starrocks/visibility/versioned/v1.0/manifest.json @@ -0,0 +1,8 @@ +{ + "CurrVersion": "1.0", + "MinCompatibleVersion": "0.1", + "Description": "base version of visibility schema", + "SchemaUpdateCqlFiles": [ + "schema.sql" + ] +} diff --git a/schema/starrocks/visibility/versioned/v1.0/schema.sql b/schema/starrocks/visibility/versioned/v1.0/schema.sql new file mode 100644 index 00000000000..fe0ce2503c3 --- /dev/null +++ b/schema/starrocks/visibility/versioned/v1.0/schema.sql @@ -0,0 +1,23 @@ +CREATE TABLE executions_visibility ( + namespace_id CHAR(64) NOT NULL, + run_id CHAR(64) NOT NULL, + start_time DATETIME(6) NOT NULL, + execution_time DATETIME(6) NOT NULL, + workflow_id VARCHAR(255) NOT NULL, + workflow_type_name VARCHAR(255) NOT NULL, + status INT NOT NULL, -- enum WorkflowExecutionStatus {RUNNING, COMPLETED, FAILED, CANCELED, TERMINATED, CONTINUED_AS_NEW, TIMED_OUT} + close_time DATETIME(6) NULL, + history_length BIGINT, + memo BLOB, + encoding VARCHAR(64) NOT NULL, + task_queue VARCHAR(255) DEFAULT '' NOT NULL, + + PRIMARY KEY (namespace_id, run_id) +); + +CREATE INDEX by_type_start_time ON executions_visibility (namespace_id, workflow_type_name, status, start_time DESC, run_id); +CREATE INDEX by_workflow_id_start_time ON executions_visibility (namespace_id, workflow_id, status, start_time DESC, run_id); +CREATE INDEX by_status_by_start_time ON executions_visibility (namespace_id, status, start_time DESC, run_id); +CREATE INDEX by_type_close_time ON executions_visibility (namespace_id, workflow_type_name, status, close_time DESC, run_id); +CREATE INDEX by_workflow_id_close_time ON executions_visibility (namespace_id, workflow_id, status, close_time DESC, run_id); +CREATE INDEX by_status_by_close_time ON executions_visibility (namespace_id, status, close_time DESC, run_id); diff --git a/schema/starrocks/visibility/versioned/v1.1/index.sql b/schema/starrocks/visibility/versioned/v1.1/index.sql new file mode 100644 index 00000000000..52c629705a1 --- /dev/null +++ b/schema/starrocks/visibility/versioned/v1.1/index.sql @@ -0,0 +1 @@ +CREATE INDEX by_close_time_by_status ON executions_visibility (namespace_id, close_time DESC, run_id, status); diff --git a/schema/starrocks/visibility/versioned/v1.1/manifest.json b/schema/starrocks/visibility/versioned/v1.1/manifest.json new file mode 100644 index 00000000000..bdd6fe5b283 --- /dev/null +++ b/schema/starrocks/visibility/versioned/v1.1/manifest.json @@ -0,0 +1,8 @@ +{ + "CurrVersion": "1.1", + "MinCompatibleVersion": "0.1", + "Description": "add close time & status index", + "SchemaUpdateCqlFiles": [ + "index.sql" + ] +} diff --git a/schema/starrocks/visibility/versioned/v1.2/advanced_visibility.sql b/schema/starrocks/visibility/versioned/v1.2/advanced_visibility.sql new file mode 100644 index 00000000000..b70347d5a0a --- /dev/null +++ b/schema/starrocks/visibility/versioned/v1.2/advanced_visibility.sql @@ -0,0 +1,128 @@ +-- Add search attributes related columns +ALTER TABLE executions_visibility + ADD COLUMN search_attributes JSON NULL, + ADD COLUMN TemporalChangeVersion JSON GENERATED ALWAYS AS (search_attributes->"$.TemporalChangeVersion"), + ADD COLUMN BinaryChecksums JSON GENERATED ALWAYS AS (search_attributes->"$.BinaryChecksums"), + ADD COLUMN BatcherUser VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>"$.BatcherUser"), + ADD COLUMN TemporalScheduledStartTime DATETIME(6) GENERATED ALWAYS AS ( + CONVERT_TZ( + REGEXP_REPLACE(search_attributes->>"$.TemporalScheduledStartTime", 'Z|[+-][0-9]{2}:[0-9]{2}$', ''), + SUBSTR(REPLACE(search_attributes->>"$.TemporalScheduledStartTime", 'Z', '+00:00'), -6, 6), + '+00:00' + ) + ), + ADD COLUMN TemporalScheduledById VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>"$.TemporalScheduledById"), + ADD COLUMN TemporalSchedulePaused BOOLEAN GENERATED ALWAYS AS (search_attributes->"$.TemporalSchedulePaused"), + ADD COLUMN TemporalNamespaceDivision VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>"$.TemporalNamespaceDivision"); + +-- Drop existing indexes +DROP INDEX by_type_start_time ON executions_visibility; +DROP INDEX by_workflow_id_start_time ON executions_visibility; +DROP INDEX by_status_by_start_time ON executions_visibility; +DROP INDEX by_type_close_time ON executions_visibility; +DROP INDEX by_workflow_id_close_time ON executions_visibility; +DROP INDEX by_status_by_close_time ON executions_visibility; +DROP INDEX by_close_time_by_status ON executions_visibility; + +-- Create new indexes +CREATE INDEX default_idx ON executions_visibility (namespace_id, (COALESCE(close_time, CAST('9999-12-31 23:59:59' AS DATETIME))) DESC, start_time DESC, run_id); +CREATE INDEX by_execution_time ON executions_visibility (namespace_id, execution_time, (COALESCE(close_time, CAST('9999-12-31 23:59:59' AS DATETIME))) DESC, start_time DESC, run_id); +CREATE INDEX by_workflow_id ON executions_visibility (namespace_id, workflow_id, (COALESCE(close_time, CAST('9999-12-31 23:59:59' AS DATETIME))) DESC, start_time DESC, run_id); +CREATE INDEX by_workflow_type ON executions_visibility (namespace_id, workflow_type_name, (COALESCE(close_time, CAST('9999-12-31 23:59:59' AS DATETIME))) DESC, start_time DESC, run_id); +CREATE INDEX by_status ON executions_visibility (namespace_id, status, (COALESCE(close_time, CAST('9999-12-31 23:59:59' AS DATETIME))) DESC, start_time DESC, run_id); +CREATE INDEX by_history_length ON executions_visibility (namespace_id, history_length, (COALESCE(close_time, CAST('9999-12-31 23:59:59' AS DATETIME))) DESC, start_time DESC, run_id); +CREATE INDEX by_task_queue ON executions_visibility (namespace_id, task_queue, (COALESCE(close_time, CAST('9999-12-31 23:59:59' AS DATETIME))) DESC, start_time DESC, run_id); + +-- Indexes for the predefined search attributes +CREATE INDEX by_temporal_change_version ON executions_visibility (namespace_id, (CAST(TemporalChangeVersion AS CHAR(255) ARRAY)), (COALESCE(close_time, CAST('9999-12-31 23:59:59' AS DATETIME))) DESC, start_time DESC, run_id); +CREATE INDEX by_binary_checksums ON executions_visibility (namespace_id, (CAST(BinaryChecksums AS CHAR(255) ARRAY)), (COALESCE(close_time, CAST('9999-12-31 23:59:59' AS DATETIME))) DESC, start_time DESC, run_id); +CREATE INDEX by_batcher_user ON executions_visibility (namespace_id, BatcherUser, (COALESCE(close_time, CAST('9999-12-31 23:59:59' AS DATETIME))) DESC, start_time DESC, run_id); +CREATE INDEX by_temporal_scheduled_start_time ON executions_visibility (namespace_id, TemporalScheduledStartTime, (COALESCE(close_time, CAST('9999-12-31 23:59:59' AS DATETIME))) DESC, start_time DESC, run_id); +CREATE INDEX by_temporal_scheduled_by_id ON executions_visibility (namespace_id, TemporalScheduledById, (COALESCE(close_time, CAST('9999-12-31 23:59:59' AS DATETIME))) DESC, start_time DESC, run_id); +CREATE INDEX by_temporal_schedule_paused ON executions_visibility (namespace_id, TemporalSchedulePaused, (COALESCE(close_time, CAST('9999-12-31 23:59:59' AS DATETIME))) DESC, start_time DESC, run_id); +CREATE INDEX by_temporal_namespace_division ON executions_visibility (namespace_id, TemporalNamespaceDivision, (COALESCE(close_time, CAST('9999-12-31 23:59:59' AS DATETIME))) DESC, start_time DESC, run_id); + + +-- Custom search attributes +CREATE TABLE custom_search_attributes ( + namespace_id CHAR(64) NOT NULL, + run_id CHAR(64) NOT NULL, + search_attributes JSON NULL, + Bool01 BOOLEAN GENERATED ALWAYS AS (search_attributes->"$.Bool01"), + Bool02 BOOLEAN GENERATED ALWAYS AS (search_attributes->"$.Bool02"), + Bool03 BOOLEAN GENERATED ALWAYS AS (search_attributes->"$.Bool03"), + Datetime01 DATETIME(6) GENERATED ALWAYS AS ( + CONVERT_TZ( + REGEXP_REPLACE(search_attributes->>"$.Datetime01", 'Z|[+-][0-9]{2}:[0-9]{2}$', ''), + SUBSTR(REPLACE(search_attributes->>"$.Datetime01", 'Z', '+00:00'), -6, 6), + '+00:00' + ) + ), + Datetime02 DATETIME(6) GENERATED ALWAYS AS ( + CONVERT_TZ( + REGEXP_REPLACE(search_attributes->>"$.Datetime02", 'Z|[+-][0-9]{2}:[0-9]{2}$', ''), + SUBSTR(REPLACE(search_attributes->>"$.Datetime02", 'Z', '+00:00'), -6, 6), + '+00:00' + ) + ), + Datetime03 DATETIME(6) GENERATED ALWAYS AS ( + CONVERT_TZ( + REGEXP_REPLACE(search_attributes->>"$.Datetime03", 'Z|[+-][0-9]{2}:[0-9]{2}$', ''), + SUBSTR(REPLACE(search_attributes->>"$.Datetime03", 'Z', '+00:00'), -6, 6), + '+00:00' + ) + ), + Double01 DECIMAL(20, 5) GENERATED ALWAYS AS (search_attributes->"$.Double01"), + Double02 DECIMAL(20, 5) GENERATED ALWAYS AS (search_attributes->"$.Double02"), + Double03 DECIMAL(20, 5) GENERATED ALWAYS AS (search_attributes->"$.Double03"), + Int01 BIGINT GENERATED ALWAYS AS (search_attributes->"$.Int01"), + Int02 BIGINT GENERATED ALWAYS AS (search_attributes->"$.Int02"), + Int03 BIGINT GENERATED ALWAYS AS (search_attributes->"$.Int03"), + Keyword01 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>"$.Keyword01"), + Keyword02 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>"$.Keyword02"), + Keyword03 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>"$.Keyword03"), + Keyword04 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>"$.Keyword04"), + Keyword05 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>"$.Keyword05"), + Keyword06 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>"$.Keyword06"), + Keyword07 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>"$.Keyword07"), + Keyword08 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>"$.Keyword08"), + Keyword09 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>"$.Keyword09"), + Keyword10 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>"$.Keyword10"), + Text01 TEXT GENERATED ALWAYS AS (search_attributes->>"$.Text01") STORED, + Text02 TEXT GENERATED ALWAYS AS (search_attributes->>"$.Text02") STORED, + Text03 TEXT GENERATED ALWAYS AS (search_attributes->>"$.Text03") STORED, + KeywordList01 JSON GENERATED ALWAYS AS (search_attributes->"$.KeywordList01"), + KeywordList02 JSON GENERATED ALWAYS AS (search_attributes->"$.KeywordList02"), + KeywordList03 JSON GENERATED ALWAYS AS (search_attributes->"$.KeywordList03"), + + PRIMARY KEY (namespace_id, run_id) +); + +CREATE INDEX by_bool_01 ON custom_search_attributes (namespace_id, Bool01); +CREATE INDEX by_bool_02 ON custom_search_attributes (namespace_id, Bool02); +CREATE INDEX by_bool_03 ON custom_search_attributes (namespace_id, Bool03); +CREATE INDEX by_datetime_01 ON custom_search_attributes (namespace_id, Datetime01); +CREATE INDEX by_datetime_02 ON custom_search_attributes (namespace_id, Datetime02); +CREATE INDEX by_datetime_03 ON custom_search_attributes (namespace_id, Datetime03); +CREATE INDEX by_double_01 ON custom_search_attributes (namespace_id, Double01); +CREATE INDEX by_double_02 ON custom_search_attributes (namespace_id, Double02); +CREATE INDEX by_double_03 ON custom_search_attributes (namespace_id, Double03); +CREATE INDEX by_int_01 ON custom_search_attributes (namespace_id, Int01); +CREATE INDEX by_int_02 ON custom_search_attributes (namespace_id, Int02); +CREATE INDEX by_int_03 ON custom_search_attributes (namespace_id, Int03); +CREATE INDEX by_keyword_01 ON custom_search_attributes (namespace_id, Keyword01); +CREATE INDEX by_keyword_02 ON custom_search_attributes (namespace_id, Keyword02); +CREATE INDEX by_keyword_03 ON custom_search_attributes (namespace_id, Keyword03); +CREATE INDEX by_keyword_04 ON custom_search_attributes (namespace_id, Keyword04); +CREATE INDEX by_keyword_05 ON custom_search_attributes (namespace_id, Keyword05); +CREATE INDEX by_keyword_06 ON custom_search_attributes (namespace_id, Keyword06); +CREATE INDEX by_keyword_07 ON custom_search_attributes (namespace_id, Keyword07); +CREATE INDEX by_keyword_08 ON custom_search_attributes (namespace_id, Keyword08); +CREATE INDEX by_keyword_09 ON custom_search_attributes (namespace_id, Keyword09); +CREATE INDEX by_keyword_10 ON custom_search_attributes (namespace_id, Keyword10); +CREATE FULLTEXT INDEX by_text_01 ON custom_search_attributes (Text01); +CREATE FULLTEXT INDEX by_text_02 ON custom_search_attributes (Text02); +CREATE FULLTEXT INDEX by_text_03 ON custom_search_attributes (Text03); +CREATE INDEX by_keyword_list_01 ON custom_search_attributes (namespace_id, (CAST(KeywordList01 AS CHAR(255) ARRAY))); +CREATE INDEX by_keyword_list_02 ON custom_search_attributes (namespace_id, (CAST(KeywordList02 AS CHAR(255) ARRAY))); +CREATE INDEX by_keyword_list_03 ON custom_search_attributes (namespace_id, (CAST(KeywordList03 AS CHAR(255) ARRAY))); diff --git a/schema/starrocks/visibility/versioned/v1.2/manifest.json b/schema/starrocks/visibility/versioned/v1.2/manifest.json new file mode 100644 index 00000000000..3d31b79f6bc --- /dev/null +++ b/schema/starrocks/visibility/versioned/v1.2/manifest.json @@ -0,0 +1,8 @@ +{ + "CurrVersion": "1.2", + "MinCompatibleVersion": "0.1", + "Description": "update schema to support advanced visibility", + "SchemaUpdateCqlFiles": [ + "advanced_visibility.sql" + ] +} diff --git a/schema/starrocks/visibility/versioned/v1.3/add_build_ids_search_attribute.sql b/schema/starrocks/visibility/versioned/v1.3/add_build_ids_search_attribute.sql new file mode 100644 index 00000000000..b38936f7444 --- /dev/null +++ b/schema/starrocks/visibility/versioned/v1.3/add_build_ids_search_attribute.sql @@ -0,0 +1,2 @@ +ALTER TABLE executions_visibility ADD COLUMN BuildIds JSON GENERATED ALWAYS AS (search_attributes->'$.BuildIds'); +CREATE INDEX by_build_ids ON executions_visibility (namespace_id, (CAST(BuildIds AS CHAR(255) ARRAY)), (COALESCE(close_time, CAST('9999-12-31 23:59:59' AS DATETIME))) DESC, start_time DESC, run_id); diff --git a/schema/starrocks/visibility/versioned/v1.3/add_history_size_bytes.sql b/schema/starrocks/visibility/versioned/v1.3/add_history_size_bytes.sql new file mode 100644 index 00000000000..4a97b64394d --- /dev/null +++ b/schema/starrocks/visibility/versioned/v1.3/add_history_size_bytes.sql @@ -0,0 +1,2 @@ +ALTER TABLE executions_visibility ADD COLUMN history_size_bytes BIGINT NULL; +CREATE INDEX by_history_size_bytes ON executions_visibility (namespace_id, history_size_bytes, (COALESCE(close_time, CAST('9999-12-31 23:59:59' AS DATETIME))) DESC, start_time DESC, run_id); diff --git a/schema/starrocks/visibility/versioned/v1.3/manifest.json b/schema/starrocks/visibility/versioned/v1.3/manifest.json new file mode 100644 index 00000000000..5c9a6ae8be6 --- /dev/null +++ b/schema/starrocks/visibility/versioned/v1.3/manifest.json @@ -0,0 +1,9 @@ +{ + "CurrVersion": "1.3", + "MinCompatibleVersion": "0.1", + "Description": "add history size bytes and build IDs visibility columns and indices", + "SchemaUpdateCqlFiles": [ + "add_history_size_bytes.sql", + "add_build_ids_search_attribute.sql" + ] +} diff --git a/schema/starrocks/visibility/versioned/v1.4/add_execution_duration.sql b/schema/starrocks/visibility/versioned/v1.4/add_execution_duration.sql new file mode 100644 index 00000000000..b5e5a3dbb82 --- /dev/null +++ b/schema/starrocks/visibility/versioned/v1.4/add_execution_duration.sql @@ -0,0 +1,2 @@ +ALTER TABLE executions_visibility ADD COLUMN execution_duration BIGINT NULL; +CREATE INDEX by_execution_duration ON executions_visibility (namespace_id, execution_duration, (COALESCE(close_time, CAST('9999-12-31 23:59:59' AS DATETIME))) DESC, start_time DESC, run_id); diff --git a/schema/starrocks/visibility/versioned/v1.4/add_parent_workflow_info.sql b/schema/starrocks/visibility/versioned/v1.4/add_parent_workflow_info.sql new file mode 100644 index 00000000000..abdb233edda --- /dev/null +++ b/schema/starrocks/visibility/versioned/v1.4/add_parent_workflow_info.sql @@ -0,0 +1,4 @@ +ALTER TABLE executions_visibility ADD COLUMN parent_workflow_id VARCHAR(255) NULL; +ALTER TABLE executions_visibility ADD COLUMN parent_run_id VARCHAR(255) NULL; +CREATE INDEX by_parent_workflow_id ON executions_visibility (namespace_id, parent_workflow_id, (COALESCE(close_time, CAST('9999-12-31 23:59:59' AS DATETIME))) DESC, start_time DESC, run_id); +CREATE INDEX by_parent_run_id ON executions_visibility (namespace_id, parent_run_id, (COALESCE(close_time, CAST('9999-12-31 23:59:59' AS DATETIME))) DESC, start_time DESC, run_id); diff --git a/schema/starrocks/visibility/versioned/v1.4/add_state_transition_count.sql b/schema/starrocks/visibility/versioned/v1.4/add_state_transition_count.sql new file mode 100644 index 00000000000..3b3894c0b64 --- /dev/null +++ b/schema/starrocks/visibility/versioned/v1.4/add_state_transition_count.sql @@ -0,0 +1,2 @@ +ALTER TABLE executions_visibility ADD COLUMN state_transition_count BIGINT NULL; +CREATE INDEX by_state_transition_count ON executions_visibility (namespace_id, state_transition_count, (COALESCE(close_time, CAST('9999-12-31 23:59:59' AS DATETIME))) DESC, start_time DESC, run_id); diff --git a/schema/starrocks/visibility/versioned/v1.4/manifest.json b/schema/starrocks/visibility/versioned/v1.4/manifest.json new file mode 100644 index 00000000000..8d9482a647c --- /dev/null +++ b/schema/starrocks/visibility/versioned/v1.4/manifest.json @@ -0,0 +1,10 @@ +{ + "CurrVersion": "1.4", + "MinCompatibleVersion": "0.1", + "Description": "add execution duration, state transition count and parent workflow info columns, and indices", + "SchemaUpdateCqlFiles": [ + "add_execution_duration.sql", + "add_state_transition_count.sql", + "add_parent_workflow_info.sql" + ] +} diff --git a/schema/starrocks/visibility/versioned/v1.5/add_root_workflow_info.sql b/schema/starrocks/visibility/versioned/v1.5/add_root_workflow_info.sql new file mode 100644 index 00000000000..907917fd1b4 --- /dev/null +++ b/schema/starrocks/visibility/versioned/v1.5/add_root_workflow_info.sql @@ -0,0 +1,4 @@ +ALTER TABLE executions_visibility ADD COLUMN root_workflow_id VARCHAR(255) NULL; +ALTER TABLE executions_visibility ADD COLUMN root_run_id VARCHAR(255) NULL; +CREATE INDEX by_root_workflow_id ON executions_visibility (namespace_id, root_workflow_id, (COALESCE(close_time, CAST('9999-12-31 23:59:59' AS DATETIME))) DESC, start_time DESC, run_id); +CREATE INDEX by_root_run_id ON executions_visibility (namespace_id, root_run_id, (COALESCE(close_time, CAST('9999-12-31 23:59:59' AS DATETIME))) DESC, start_time DESC, run_id); diff --git a/schema/starrocks/visibility/versioned/v1.5/manifest.json b/schema/starrocks/visibility/versioned/v1.5/manifest.json new file mode 100644 index 00000000000..04f3f0fa1dc --- /dev/null +++ b/schema/starrocks/visibility/versioned/v1.5/manifest.json @@ -0,0 +1,8 @@ +{ + "CurrVersion": "1.5", + "MinCompatibleVersion": "0.1", + "Description": "add root workflow info columns and indices", + "SchemaUpdateCqlFiles": [ + "add_root_workflow_info.sql" + ] +} diff --git a/schema/starrocks/visibility/versioned/v1.6/fix_root_workflow_info.sql b/schema/starrocks/visibility/versioned/v1.6/fix_root_workflow_info.sql new file mode 100644 index 00000000000..68a853eb58e --- /dev/null +++ b/schema/starrocks/visibility/versioned/v1.6/fix_root_workflow_info.sql @@ -0,0 +1,9 @@ +DROP INDEX by_root_workflow_id ON executions_visibility; +DROP INDEX by_root_run_id ON executions_visibility; +ALTER TABLE executions_visibility DROP COLUMN root_workflow_id; +ALTER TABLE executions_visibility DROP COLUMN root_run_id; + +ALTER TABLE executions_visibility ADD COLUMN root_workflow_id VARCHAR(255) NOT NULL DEFAULT ''; +ALTER TABLE executions_visibility ADD COLUMN root_run_id VARCHAR(255) NOT NULL DEFAULT ''; +CREATE INDEX by_root_workflow_id ON executions_visibility (namespace_id, root_workflow_id, (COALESCE(close_time, CAST('9999-12-31 23:59:59' AS DATETIME))) DESC, start_time DESC, run_id); +CREATE INDEX by_root_run_id ON executions_visibility (namespace_id, root_run_id, (COALESCE(close_time, CAST('9999-12-31 23:59:59' AS DATETIME))) DESC, start_time DESC, run_id); diff --git a/schema/starrocks/visibility/versioned/v1.6/manifest.json b/schema/starrocks/visibility/versioned/v1.6/manifest.json new file mode 100644 index 00000000000..43e52bc1a5e --- /dev/null +++ b/schema/starrocks/visibility/versioned/v1.6/manifest.json @@ -0,0 +1,8 @@ +{ + "CurrVersion": "1.6", + "MinCompatibleVersion": "0.1", + "Description": "fix root workflow info columns", + "SchemaUpdateCqlFiles": [ + "fix_root_workflow_info.sql" + ] +} diff --git a/schema/starrocks/visibility/versioned/v1.7/add_pause_info_search_attribute.sql b/schema/starrocks/visibility/versioned/v1.7/add_pause_info_search_attribute.sql new file mode 100644 index 00000000000..b5465a0ca53 --- /dev/null +++ b/schema/starrocks/visibility/versioned/v1.7/add_pause_info_search_attribute.sql @@ -0,0 +1,2 @@ +ALTER TABLE executions_visibility ADD COLUMN TemporalPauseInfo JSON GENERATED ALWAYS AS (search_attributes->'$.TemporalPauseInfo'); +CREATE INDEX by_temporal_pause_info ON executions_visibility (namespace_id, (CAST(TemporalPauseInfo AS CHAR(255) ARRAY)), (COALESCE(close_time, CAST('9999-12-31 23:59:59' AS DATETIME))) DESC, start_time DESC, run_id); diff --git a/schema/starrocks/visibility/versioned/v1.7/manifest.json b/schema/starrocks/visibility/versioned/v1.7/manifest.json new file mode 100644 index 00000000000..a0ab2b3c146 --- /dev/null +++ b/schema/starrocks/visibility/versioned/v1.7/manifest.json @@ -0,0 +1,8 @@ +{ + "CurrVersion": "1.7", + "MinCompatibleVersion": "0.1", + "Description": "add TemporalPauseInfo column", + "SchemaUpdateCqlFiles": [ + "add_pause_info_search_attribute.sql" + ] +} diff --git a/schema/starrocks/visibility/versioned/v1.8/add_deployment_search_attributes.sql b/schema/starrocks/visibility/versioned/v1.8/add_deployment_search_attributes.sql new file mode 100644 index 00000000000..13568dce850 --- /dev/null +++ b/schema/starrocks/visibility/versioned/v1.8/add_deployment_search_attributes.sql @@ -0,0 +1,7 @@ +ALTER TABLE executions_visibility ADD COLUMN TemporalWorkerDeploymentVersion VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>"$.TemporalWorkerDeploymentVersion"); +ALTER TABLE executions_visibility ADD COLUMN TemporalWorkflowVersioningBehavior VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>"$.TemporalWorkflowVersioningBehavior"); +ALTER TABLE executions_visibility ADD COLUMN TemporalWorkerDeployment VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>"$.TemporalWorkerDeployment"); + +CREATE INDEX by_temporal_worker_deployment_version ON executions_visibility (namespace_id, TemporalWorkerDeploymentVersion, (COALESCE(close_time, CAST('9999-12-31 23:59:59' AS DATETIME))) DESC, start_time DESC, run_id); +CREATE INDEX by_temporal_workflow_versioning_behavior ON executions_visibility (namespace_id, TemporalWorkflowVersioningBehavior, (COALESCE(close_time, CAST('9999-12-31 23:59:59' AS DATETIME))) DESC, start_time DESC, run_id); +CREATE INDEX by_temporal_worker_deployment ON executions_visibility (namespace_id, TemporalWorkerDeployment, (COALESCE(close_time, CAST('9999-12-31 23:59:59' AS DATETIME))) DESC, start_time DESC, run_id); diff --git a/schema/starrocks/visibility/versioned/v1.8/manifest.json b/schema/starrocks/visibility/versioned/v1.8/manifest.json new file mode 100644 index 00000000000..067360e2732 --- /dev/null +++ b/schema/starrocks/visibility/versioned/v1.8/manifest.json @@ -0,0 +1,8 @@ +{ + "CurrVersion": "1.8", + "MinCompatibleVersion": "0.1", + "Description": "add TemporalWorkerDeploymentVersion, TemporalWorkerDeployment, and TemporalWorkflowVersioningBehavior columns", + "SchemaUpdateCqlFiles": [ + "add_deployment_search_attributes.sql" + ] +} diff --git a/schema/starrocks/visibility/versioned/v1.9/add_version_column.sql b/schema/starrocks/visibility/versioned/v1.9/add_version_column.sql new file mode 100644 index 00000000000..2c8b6ed860b --- /dev/null +++ b/schema/starrocks/visibility/versioned/v1.9/add_version_column.sql @@ -0,0 +1,2 @@ +ALTER TABLE executions_visibility ADD COLUMN _version BIGINT NOT NULL DEFAULT 0; +ALTER TABLE custom_search_attributes ADD COLUMN _version BIGINT NOT NULL DEFAULT 0; diff --git a/schema/starrocks/visibility/versioned/v1.9/manifest.json b/schema/starrocks/visibility/versioned/v1.9/manifest.json new file mode 100644 index 00000000000..0d8f6da9013 --- /dev/null +++ b/schema/starrocks/visibility/versioned/v1.9/manifest.json @@ -0,0 +1,8 @@ +{ + "CurrVersion": "1.9", + "MinCompatibleVersion": "0.1", + "Description": "add _version column", + "SchemaUpdateCqlFiles": [ + "add_version_column.sql" + ] +}