Skip to content

Conversation

@alxtkr77
Copy link
Member

@alxtkr77 alxtkr77 commented Dec 24, 2025

Summary

  • Fix bug where set_credentials() returns early without creating TSDB tables when the same credentials are already set
  • This caused UndefinedTable errors if tables were deleted or didn't exist yet
  • The fix calls _create_tsdb_tables() before the early return, which is safe because all TSDB connectors use idempotent table creation

…set (ML-11807)

When set_credentials() is called with the same credentials that are already
configured, the code returned early without calling _create_tsdb_tables().
This caused "UndefinedTable" errors if the TSDB tables were deleted or didn't
exist yet.

The fix ensures _create_tsdb_tables() is always called, even on the early
return path. This is safe because all TSDB connector implementations use
idempotent table creation:
- V3IO: if_exists=v3io_frames.IGNORE
- TDEngine: CREATE STABLE IF NOT EXISTS
- TimescaleDB: CREATE TABLE IF NOT EXISTS
)
# Even if credentials match, ensure TSDB tables exist (ML-11807).
# This handles cases where tables were deleted or don't exist yet.
# The create_tables() call is idempotent (uses CREATE TABLE IF NOT EXISTS).
Copy link
Collaborator

Choose a reason for hiding this comment

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

This depends on the connector though. Are they all idempotent? They don't all use CREATE TABLE IF NOT EXISTS, that's certain.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It seems like the answer is that they are idempotent, so just need to clear up the comment.

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

Comment on lines +1834 to +1836
tsdb_profile = self._validate_and_get_tsdb_profile(
tsdb_profile_name
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we also need to

            secrets_dict[
                mlrun.common.schemas.model_monitoring.ProjectSecretKeys.TSDB_PROFILE_NAME
            ] = tsdb_profile_name

?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, we don't need to set secrets_dict here.

This is the early return path where credentials are already stored in project secrets:

  1. check_if_credentials_are_set() (line 1824) confirmed credentials exist
  2. _is_the_same_cred() (line 1825) confirmed they match the provided values
  3. We return at line 1838, never reaching store_project_secrets() (line 1880)

The secrets_dict variable is only used later to store secrets, but since the credentials are already stored correctly, we just need to ensure the TSDB tables exist.

@assaf758 assaf758 merged commit b8cb25f into mlrun:development Dec 24, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants