Skip to content

Conversation

tenfyzhong
Copy link
Contributor

@tenfyzhong tenfyzhong commented Aug 25, 2025

What problem does this PR solve?

Issue Number: close #1755

This PR primarily addresses two main areas:

  1. Terminology Clarity: The term "namespace" has been replaced with "keyspace" across the codebase, particularly in API endpoints, internal data structures, and etcd keys. This change aims to provide a more precise and less ambiguous term for the logical grouping of changefeeds, aligning with the concept of keyspaces used in distributed data systems and avoiding potential confusion with other system-level namespaces. This PR completes the comprehensive refactoring initiated in previous efforts.
  2. API Robustness and Validation: A new middleware is introduced to validate the keyspace parameter in API requests, ensuring that only valid and ENABLED keyspaces are processed, thus enhancing the API's reliability and user experience.

What is changed and how it works?

This PR introduces a significant refactoring to replace the term "namespace" with "keyspace" across the TiCDC codebase to enhance clarity and consistency, and adds a keyspace validation middleware.

  • Core Terminology Renaming:

    • The namespace field in heartbeatpb.ChangefeedID is now deprecated, and a new keyspace field has been added.
    • common.DefaultNamespace has been renamed to common.DefaultKeyspace.
    • The Namespace field in common.ChangeFeedDisplayName has been renamed to Keyspace.
    • All constructors and accessors for common.ChangeFeedID and common.ChangeFeedDisplayName (e.g., NewChangefeedID, NewChangeFeedIDWithName, NewChangefeedID4Test, Namespace()) have been updated to reflect the Keyspace change and use Keyspace().
    • The ValidateNamespace function has been renamed to ValidateKeyspace, and its associated regular expression (namespaceRe) and maximum length constant (namespaceMaxLen) have been updated to keyspaceRe and keyspaceMaxLen.
    • The error errors.ErrInvalidNamespace has been renamed to errors.ErrInvalidKeyspace.
  • API Endpoint Updates (api/v1/api.go, api/v2/changefeed.go, pkg/api/util.go):

    • api.APIOpVarNamespace has been renamed to api.APIOpVarKeyspace.
    • The GetNamespaceValueWithDefault function has been renamed to GetKeyspaceValueWithDefault.
    • All relevant API endpoints (e.g., CreateChangefeed, ListChangefeeds, GetChangeFeed, DeleteChangefeed, PauseChangefeed, ResumeChangefeed, UpdateChangefeed, MoveTable, MoveSplitTable, SplitTableByRegionCount, MergeTable, ListTables, getDispatcherCount, status, syncState) now use GetKeyspaceValueWithDefault(c) instead of GetNamespaceValueWithDefault(c).
    • Swagger documentation comments for API parameters have been updated from namespace to keyspace.
    • JSON fields in API models (api/v1/api.go, api/v2/model.go, tests/integration_tests/api_v2/model.go) such as ChangefeedConfig.Namespace, ChangefeedCommonInfo.Namespace, ProcessorCommonInfo.Namespace, and ChangeFeedInfo.Namespace have been renamed to Keyspace.
    • API client interfaces and their implementations in pkg/api/v2/changefeed.go and pkg/api/v2/processor.go now correctly use keyspace parameters.
  • CLI Tooling Updates (cmd/cdc/cli/*):

    • All cdc cli commands (e.g., create, list, pause, resume, remove, query, update, move-table, merge-table, split-table-by-region-count) have updated their flags and internal variables from namespace to keyspace.
  • Coordinator Logic Adjustments:

    • coordinator.Controller.ListChangefeeds now accepts a keyspace parameter and uses ChangefeedDB.GetAllChangefeedsByKeyspace to filter changefeeds.
    • A new method ChangefeedDB.GetAllChangefeedsByKeyspace(keyspace string) has been added to retrieve changefeeds specific to a given keyspace.
    • coordinator.Controller.calculateGCSafepoint has been renamed to calculateGlobalGCSafepoint.
    • A new method coordinator.Controller.calculateKeyspaceGCBarrier has been added to calculate keyspace-specific GC barriers.
    • coordinator.coordinator.updateGCSafepoint now conditionally calls updateGlobalGcSafepoint or updateAllKeyspaceGcBarriers.
    • coordinator.coordinator.CreateChangefeed and RemoveChangefeed now call updateGCSafepointByChangefeed.
    • Log messages in coordinator/changefeed/backoff.go, coordinator/orchestrator/reactor_state.go, and other coordinator components have been updated to refer to keyspace instead of namespace.
  • Etcd Key Management Refactoring:

    • etcd.NamespacedPrefix has been renamed to etcd.KeyspacePrefix.
    • etcd.DefaultClusterAndNamespacePrefix has been renamed to etcd.DefaultClusterAndKeyspacePrefix.
    • Functions responsible for generating etcd keys (TaskPositionKeyPrefix, ChangefeedStatusKeyPrefix, GetEtcdKeyChangeFeedList, GetEtcdKeyChangeFeedInfo, GetEtcdKeyJob) have been updated to use the new Keyspace terminology.
    • etcd.CDCKey now includes a Keyspace field.
  • Downstream Adapter and Sink Components:

    • Metrics labels (e.g., TableTriggerEventDispatcherGauge, EventDispatcherGauge, CreateDispatcherDuration, CheckpointTsMessageDuration, WorkerBatchDuration, ConflictDetectDuration, RedoFlushLogDurationHistogram, CloudStorageWriteBytesGauge, ClaimCheckSendMessageDuration, etc.) across downstreamadapter/dispatchermanager, downstreamadapter/sink/cloudstorage, downstreamadapter/sink/kafka, downstreamadapter/sink/mysql/causality, downstreamadapter/sink/mysql, downstreamadapter/sink/pulsar, downstreamadapter/sink/redo, pkg/sink/codec/avro, pkg/sink/codec/common, pkg/sink/codec/encoder_group, pkg/sink/kafka/claimcheck, pkg/sink/kafka/metrics_collector, pkg/sink/pulsar have been updated from namespace to keyspace.
    • Log messages in various sink components (e.g., cloudstorage/sink.go, kafka/sink.go, pulsar/dml_producer.go, redo/meta.go) now use keyspace.
    • Redo log file naming in pkg/redo/writer/file/file.go and pkg/redo/writer/memory/file_worker.go has been updated to use common.DefaultKeyspace.
    • Pulsar topic expression validation message in downstreamadapter/sink/eventrouter/topic/expression.go has been updated.
    • Kafka client ID generation (pkg/sink/kafka/options.go) and MySQL TLS configuration names (pkg/sink/mysql/config.go) now include keyspace.
  • Migration Logic Updates (pkg/migrate/migrate.go):

    • The migration logic has been adjusted to handle the transition from the old "namespace" concept to the new "keyspace" concept, ensuring backward compatibility and proper data migration by setting ChangefeedID.DisplayName.Keyspace to common.DefaultKeyspace for existing changefeeds.
  • New Feature: Keyspace Validation Middleware (api/middleware/middleware.go):

    • Introduced KeyspaceCheckerMiddleware which validates the keyspace query parameter in incoming API requests. This middleware uses pkg/pdutil.PDAPIClient.LoadKeyspace to check if the specified keyspace exists and is in an ENABLED state in PD.
    • The pkg/pdutil.PDAPIClient interface and its implementation have been extended with a LoadKeyspace method to facilitate this validation.
    • Added unit tests for KeyspaceCheckerMiddleware.
  • Other Minor Changes:

    • Updated JobTableID and JobHistoryID imports from github.com/pingcap/tidb/pkg/ddl to github.com/pingcap/tidb/pkg/meta/metadef in logservice/schemastore/ddl_job_fetcher.go.
    • Updated session.SetSchemaLease to vardef.SetSchemaLease in pkg/common/event/util.go.
    • Updated topologyTiDB and topologyTiDBTTL imports from github.com/pingcap/tidb/pkg/domain/infosync to github.com/pingcap/tidb/pkg/domain/serverinfo in pkg/upstream/topo.go.
    • Introduced new metrics minGCBarrierGauge and cdcGCBarrierGauge with a namespace label (which should be interpreted as keyspace) in pkg/txnutil/gc/metrics.go.
    • Added TryUpdateKeypsaceGCBarrier method and related structures to pkg/txnutil/gc/gc_manager.go.
    • Updated go.mod and go.sum dependencies.

Check List

Tests

  • Unit test
  • Integration test

Questions

Will it cause performance regression or break compatibility?
  • Performance Regression: Unlikely. The changes are primarily refactoring and renaming, which do not introduce significant algorithmic or data path changes. The new keyspace validation middleware involves a lightweight lookup to PD, which is cached and not expected to be a performance bottleneck under normal operating conditions.
  • Compatibility:
    • API Compatibility: This is a breaking change for clients interacting with the TiCDC API (v2). The API query parameter name for changefeed grouping (namespace) has been effectively replaced by keyspace. Clients interacting with the TiCDC API (v2) that previously used the namespace parameter will need to update their requests to use keyspace instead.
    • Data Compatibility: Migration logic (pkg/migrate) is in place to handle existing data in etcd, seamlessly transitioning from the old "namespace" structure to the new "keyspace" structure. This ensures that existing changefeeds continue to function after an upgrade.
    • Protocol Buffer Compatibility: The heartbeatpb.ChangefeedID message has been updated to include a new keyspace field, while the old namespace field is marked as deprecated. This approach maintains backward compatibility for existing protobuf consumers while enabling the transition to the new terminology.
Do you need to update user documentation, design documentation or monitoring documentation?
  • User Documentation: Yes, API documentation (especially for v2/changefeeds endpoints) must be updated to reflect the keyspace parameter. Any user guides or CLI examples referencing namespace will need to be updated to keyspace.
  • Design Documentation: Yes, any design documents discussing the logical grouping of changefeeds, etcd key structures, API design, or the new keyspace validation mechanism should be updated.
  • Monitoring Documentation: Yes, if any metrics labels previously used "namespace" and are now using "keyspace" (e.g., metrics.FinishedOperatorCount.WithLabelValues(common.DefaultKeyspace, ...)).

Release note

### API Parameter Change: 'namespace' Renamed to 'keyspace'

The API parameter `namespace` for changefeed-related operations (e.g., creating, listing, getting, deleting changefeeds) has been renamed to `keyspace`. This change provides clearer terminology for logical grouping of changefeeds.

**Impact:**
*   **Breaking Change:** Clients interacting with the TiCDC API (v2) that previously used the `namespace` parameter will need to update their requests to use `keyspace` instead.
*   **Upgrade Impact:** For existing deployments, data migration logic is included to seamlessly transition existing changefeeds from the old "namespace" concept to the new "keyspace" concept in etcd. No manual intervention is required for data.

### New Feature: Keyspace Validation

A new validation middleware has been introduced for API requests. This middleware ensures that any specified `keyspace` in a request corresponds to an existing and `ENABLED` keyspace in PD. Requests targeting non-existent or non-enabled keyspaces will be rejected with a `400 Bad Request` error.

Please update your API clients and scripts accordingly.

@ti-chi-bot ti-chi-bot bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. do-not-merge/needs-triage-completed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Aug 25, 2025
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary of Changes

Hello @tenfyzhong, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refactors the TiCDC codebase to replace the term "namespace" with "keyspace ID" for changefeed identification. This change aims to enhance terminology clarity and consistency across API endpoints, internal data structures, and etcd keys, aligning with common distributed system concepts and avoiding ambiguity.

Highlights

  • API Changes: The API parameter namespace has been replaced with keyspace_id across all relevant v2 changefeed endpoints (e.g., Create, List, Get, Delete, Pause, Resume, Update, MoveTable). A new query parameter APIOpVarKeyspaceID was introduced, and the internal GetNamespaceValueWithDefault function was renamed to GetKeyspaceValueWithDefault.
  • Core Terminology Refactoring: common.DefaultNamespace is now common.DefaultKeyspaceID. The Namespace field in common.ChangeFeedDisplayName has been renamed to KeyspaceID, and all related constructors and accessors for common.ChangeFeedID and common.ChangeFeedDisplayName have been updated to reflect this.
  • Coordinator Logic: The coordinator.Controller.ListChangefeeds method now accepts a keyspace parameter, leveraging a newly added ChangefeedDB.GetAllChangefeedsByKeyspace method to filter changefeeds by their keyspace.
  • Etcd Key Management: Etcd key prefixes and generation functions have been updated from NamespacedPrefix to KeyspaceIDPrefix and now use the new KeyspaceID terminology for changefeed information, status, and task positions.
  • Data Migration: Logic in pkg/migrate has been adjusted to ensure seamless transition of existing changefeed data from the old "namespace" concept to the new "keyspace" concept in etcd, maintaining backward compatibility.
  • Internal Components & Testing: Redo log file naming has been updated to use common.DefaultKeyspaceID, and extensive unit and integration tests across various packages have been modified to align with the new KeyspaceID terminology and API changes.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request does a great job of standardizing the terminology from 'namespace' to 'keyspace ID' across a large part of the codebase. The changes are extensive and touch many components, including APIs, internal data structures, etcd keys, and tests. The migration logic for existing data is also a crucial part of this change.

My review focuses on ensuring consistency in the new terminology, removing redundant code introduced during the refactoring, and fixing a couple of issues with metrics labeling. Overall, the changes are well-executed and move the codebase in the right direction for clarity and consistency.

@tenfyzhong
Copy link
Contributor Author

/retest-required

1 similar comment
@tenfyzhong
Copy link
Contributor Author

/retest-required

@tenfyzhong
Copy link
Contributor Author

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request standardizes the terminology by replacing 'namespace' with 'keyspace ID' across the codebase, which improves clarity and consistency. The changes are extensive, touching APIs, internal data structures, and etcd keys. The refactoring is well-executed.

I've found one critical issue in the new KeyspaceCheckerMiddleware that could cause requests for the default keyspace to hang. I've also pointed out a minor inconsistency in a JSON tag for the new Keyspace field. Overall, great work on this significant refactoring.

Copy link

ti-chi-bot bot commented Aug 27, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign flowbehappy for approval. For more information see the Code Review Process.
Please ensure that each of them provides their approval before proceeding.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@tenfyzhong tenfyzhong changed the title Standardize changefeed identification by replacing 'namespace' with 'keyspace ID' across APIs and internal structures. Introduce keyspace and refactor API, CLI, and internal components to replace namespace. Aug 27, 2025
@tenfyzhong
Copy link
Contributor Author

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request is a large-scale refactoring to replace "namespace" with "keyspace" throughout the codebase, which is a significant step towards clearer terminology. The changes are extensive and appear to be applied consistently. The introduction of the KeyspaceCheckerMiddleware is a valuable addition for API robustness. My review has identified a few areas for improvement, primarily concerning error handling in the new middleware, simplifying logic in API handlers for better clarity, and ensuring consistency in CLI flags.

}

if meta.State != keyspacepb.KeyspaceState_ENABLED {
c.IndentedJSON(http.StatusBadRequest, errors.ErrAPIInvalidParam)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The error errors.ErrAPIInvalidParam is too generic. When a keyspace is not enabled, providing a more specific error message would improve the user experience. Consider generating a more descriptive error message.

Suggested change
c.IndentedJSON(http.StatusBadRequest, errors.ErrAPIInvalidParam)
c.IndentedJSON(http.StatusBadRequest, errors.ErrAPIInvalidParam.GenWithStack("keyspace %s is not enabled, state: %s", keyspace, meta.State.String()))

@tenfyzhong
Copy link
Contributor Author

/retest-required

2 similar comments
@tenfyzhong
Copy link
Contributor Author

/retest-required

@tenfyzhong
Copy link
Contributor Author

/retest-required

@tenfyzhong tenfyzhong force-pushed the feat-keyspace-for-api branch 2 times, most recently from 2d2efd6 to 599b19c Compare September 2, 2025 03:35
@tenfyzhong
Copy link
Contributor Author

/retest-required

1 similar comment
@tenfyzhong
Copy link
Contributor Author

/retest-required

- Rename the API query parameter for specifying a changefeed's namespace from `namespace` to `keyspace_id`.
- Update the `CreateChangefeed` handler to retrieve the namespace value using `keyspace_id`.
- Modify `common.NewChangefeedID` and `common.NewChangeFeedIDWithName` to accept a namespace parameter, defaulting to `DefaultNamespace` if not provided.

Signed-off-by: tenfyzhong <[email protected]>
- Allow users to list changefeeds specific to a given keyspace.
- Enhance the API to provide more granular control when retrieving changefeeds.
- Update the coordinator, controller, and changefeed database to support keyspace-aware listing.

Signed-off-by: tenfyzhong <[email protected]>
…eWithDefault

- Renamed `GetNamespaceValueWithDefault` function to `GetKeyspaceValueWithDefault` to improve clarity and consistency with the `keyspace` terminology used in the API.
- Updated all call sites of the renamed function in `api/v2/changefeed.go`.
- The internal variable `namespace` within the function was also renamed to `keyspaceID`.

Signed-off-by: tenfyzhong <[email protected]>
- The constant `common.DefaultNamespace` has been renamed to `common.DefaultKeyspaceID`.
- This change improves clarity and consistency by using a more precise term for the default logical grouping of changefeeds.
- All references to the old constant have been updated across the codebase.

Signed-off-by: tenfyzhong <[email protected]>
- The term "namespace" is being replaced by "keyspace ID" to better reflect the underlying concept.
- Renamed the `NamespacedPrefix` function to `KeyspaceIDPrefix`.
- Renamed the `namespace` parameter to `keyspaceID` in the `KeyspaceIDPrefix` function.
- Updated all references and call sites to use the new function name and parameter.

Signed-off-by: tenfyzhong <[email protected]>
…mands

- Updated terminology for replication tasks to use "keyspace" instead of "namespace".
- Aligned CLI flags (e.g., `--namespace` to `--keyspace`) and internal variables with the new "keyspace" term.
- Changed the short flag from `-n` to `-k` for most changefeed commands to reflect the new name.

Signed-off-by: tenfyzhong <[email protected]>
…ntegration tests

- Update JSON payloads for changefeed creation and updates to use `keyspace`.
- Modify query parameters in API requests (GET, POST, PUT, DELETE) from `namespace` to `keyspace`.
- Rename `Namespace` fields to `Keyspace` in API v2 model structs (`ChangefeedCommonInfo`, `ChangefeedConfig`, `ProcessorCommonInfo`, `ChangeFeedInfo`).
- Update `tableInfo` struct and its usage in `move_table` integration tests to reflect the terminology change.

Signed-off-by: tenfyzhong <[email protected]>
- Removed specific author and date metadata from a code comment.
- Cleans up the comment by removing unnecessary and potentially outdated internal tracking information.

Signed-off-by: tenfyzhong <[email protected]>
…essages

- Standardize terminology by replacing `keyspace_id` with `keyspace`.
- Improve clarity and consistency in error messages and code comments.

Signed-off-by: tenfyzhong <[email protected]>
- The JSON tag for the `Keyspace` field was `Keyspace`.
- This change aligns it with common JSON naming conventions by making the first letter lowercase (`keyspace`).
- Ensures consistent API representation for change feed display names.

Signed-off-by: tenfyzhong <[email protected]>
- Implement the `LoadKeyspace` method for the `mockPDAPIClient` to support new testing scenarios.

Signed-off-by: tenfyzhong <[email protected]>
- The previous condition `changefeed.ChangefeedID.Keyspace() != keyspace` caused incorrect filtering behavior.
- Specifically, when the `keyspace` query parameter was empty (implying "all keyspaces"), it would incorrectly filter out changefeeds that had any keyspace assigned.
- This change ensures that `ListChangeFeeds` returns all changefeeds matching the state, irrespective of their keyspace, when no specific keyspace is provided.
- If specific keyspace filtering is desired, it should be implemented with a conditional check for a non-empty `keyspace` parameter.

Signed-off-by: tenfyzhong <[email protected]>
- The previous short flag '-n' could conflict with 'name' or 'namespace' in other commands.
- '-k' is more intuitive and consistent for 'keyspace'.

Signed-off-by: tenfyzhong <[email protected]>
- The `keyspace` variable, derived from the API endpoint's path, is now used to set the changefeed's keyspace when `cfg.Keyspace` is empty.
- This ensures the changefeed is created within the keyspace specified in the API request path, rather than falling back to a hardcoded default.
- Removed the explicit assignment of `changefeedID.DisplayName.Keyspace` as it is implicitly handled or derived from `changefeedID.Keyspace()`.

Signed-off-by: tenfyzhong <[email protected]>
- The keyspace for a new changefeed can now be specified using a `keyspace` query parameter.
- This query parameter will take precedence over any keyspace provided in the request body.
- Updated OpenAPI specification to reflect the new `keyspace` query parameter.

Signed-off-by: tenfyzhong <[email protected]>
- Renamed `CalculateGCSafepoint` to `CalculateGlobalGCSafepoint` to clarify its global scope.
- Added `CalculateKeyspaceGCBarrier` to compute the minimum checkpoint timestamp for each keyspace.
- Implemented `TryUpdateKeypsaceGCBarrier` in `gcManager` and `SetGCBarrier` to update GC barriers for individual keyspaces.
- Updated coordinator logic to support keyspace-specific GC barrier updates, conditionally enabling it for future keyspace management.
- Added `ErrUpdateGCBarrierFailed` and `ErrLoadKeyspaceFailed` for keyspace GC operations.
- This change enables more granular GC control by allowing different keyspaces to have independent GC barriers.

Signed-off-by: tenfyzhong <[email protected]>
- Update `github.com/pingcap/tidb` to the latest version to incorporate recent fixes and features.
- Adapt to `tidb` API changes, including:
    - Moving `infosync` package to `serverinfo`.
    - Relocating `ddl.JobTableID` and `ddl.HistoryTableID` to `metadef`.
    - Shifting `session.SetSchemaLease` to `vardef.SetSchemaLease`.
- Update various other Go module dependencies to their latest compatible versions.

Signed-off-by: tenfyzhong <[email protected]>
- Run `go mod tidy` to remove entries for unused or outdated dependencies.

Signed-off-by: tenfyzhong <[email protected]>
- The `TryUpdateKeypsaceGCBarrier` function now accepts `keyspaceName` to facilitate per-keyspace metric labeling.
- Introduced `min_gc_barrier` and `cdc_gc_barrier` Prometheus gauges.
- These gauges track the minimum and CDC GC barriers for each keyspace, labeled by the keyspace's name.
- This provides better observability into the GC progress and barriers for individual keyspaces.

Signed-off-by: tenfyzhong <[email protected]>
…g upgrades

- Ensures that `ChangefeedID` can be correctly constructed from heartbeat messages sent by older version nodes.
- If `pb.Keyspace` is empty (indicating an older node), `DisplayName.Keyspace` will fall back to using `pb.Namespace`.
- This prevents issues when upgrading, maintaining compatibility with existing deployments.

Signed-off-by: tenfyzhong <[email protected]>
- Update comment to explain that the `Namespace` field is preserved for backward compatibility during upgrades, mapping to `Keyspace`.

Signed-off-by: tenfyzhong <[email protected]>
- Remove `namespace` field from `heartbeatpb.ChangefeedID` proto message.
- Update `keyspace` field tag from `5` to `4` in `heartbeatpb.ChangefeedID`.
- Remove corresponding `Namespace` field and its logic from generated Go code.
- Remove `Namespace` cloning logic in `coordinator/changefeed.go`.
- Remove backward compatibility logic for `Namespace` in `pkg/common/types.go`.
- Simplifies the ChangefeedID structure by removing a redundant and deprecated field.

Signed-off-by: tenfyzhong <[email protected]>
- Previously, a non-existent keyspace would result in a 500 Internal Server Error.
- This change introduces a specific check for `ENTRY_NOT_FOUND` errors when loading keyspaces.
- If a keyspace does not exist, the API now returns a `400 Bad Request` with `ErrAPIInvalidParam`.
- This improves API clarity by distinguishing between internal server errors and invalid user input.
- A new helper function `IsKeyspaceNotExistError` was added to `pkg/errors` for this check.

Signed-off-by: tenfyzhong <[email protected]>
- Introduce `KeyspaceCheckerMiddleware` to validate keyspace access for all changefeed API endpoints.
- This ensures that changefeed operations are restricted to the keyspace from which the request originated, enhancing security and data isolation.

Signed-off-by: tenfyzhong <[email protected]>
… API

- The `Create` changefeed API now requires the `keyspace` as a separate argument.
- The `keyspace` is included as a query parameter in the HTTP POST request to the `/changefeeds` endpoint.
- This change ensures the API call explicitly specifies the target keyspace for changefeed creation.
- Updated the CLI command and mock interface to align with the new API signature.

Signed-off-by: tenfyzhong <[email protected]>
- Use `common.DefaultKeyspace` for the default value of the `--keyspace` flag in `cdc cli` commands.
- Pass the keyspace explicitly to the `VerifyTable` API method.
- Replace hardcoded "keyspace" query parameter strings with `api.APIOpVarKeyspace` constant in API calls for consistency.

Signed-off-by: tenfyzhong <[email protected]>
- Improve error message clarity by including the request URI when a keyspace does not exist.
- This provides more context for debugging `KeyspaceNotExistError` cases.

Signed-off-by: tenfyzhong <[email protected]>
- Revert to using the global GC safepoint update mechanism.
- The next-gen keyspace GC barrier feature is not yet ready.

Signed-off-by: tenfyzhong <[email protected]>
@tenfyzhong tenfyzhong force-pushed the feat-keyspace-for-api branch from 6ede9bd to e24a793 Compare September 3, 2025 12:21
- Activate next-gen GC barrier updates by checking `kerneltype.IsNextGen()`.
- Remove placeholder `TODO` comments for next-gen GC feature.

Signed-off-by: tenfyzhong <[email protected]>
- The `ObjPrefix` was incorrectly prepended with `subDir`, leading to a redundant and incorrect path prefix when combined with the `SubDir` option in `WalkDir`.
- This ensures that `WalkDir` correctly searches for schema files within the specified `subDir` by using a relative prefix.

Signed-off-by: tenfyzhong <[email protected]>
- The `common.NewChangeFeedIDWithName` function now requires a keyspace parameter.
- Updated all test calls to use `common.DefaultKeyspace` to align with the new API signature.
- Moved the `LoadKeyspace` mock implementation to `testutil.MockPDAPIClient` for centralization.

Signed-off-by: tenfyzhong <[email protected]>
Copy link

ti-chi-bot bot commented Sep 5, 2025

@tenfyzhong: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-unit-test d1b33d3 link true /test pull-unit-test
pull-cdc-kafka-integration-heavy d1b33d3 link true /test pull-cdc-kafka-integration-heavy
pull-cdc-mysql-integration-heavy d1b33d3 link true /test pull-cdc-mysql-integration-heavy

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Introduce keyspace to support multi-tanent
1 participant