from typing import Optional, List
from pydantic import Field, BaseModel
from enum import Enum
class TiDBProduct(str, Enum):
ALL_TIDB = "tidb"
ALL_TIDB_CLOUD = "tidb_cloud"
TIDB_CLOUD_SERVERLESS = "tidb_cloud_serverless"
TIDB_SELF_MANAGED = "tidb_self_managed"
TIDB_CLOUD_DEDICATED = "tidb_cloud_dedicated"
class TiDBComponent(str, Enum):
BR = "br"
DM = "dm"
TIDB_DASHBOARD = "tidb-dashboard"
DUMPLING = "dumpling"
LIGHTNING = "lightning"
MONITOR = "monitor"
PD = "pd"
SYNC_DIFF_CHECK = "sync-diff-check"
TICDC = "ticdc"
TIDB = "tidb"
TIDB_BINLOG = "tidb_binlog"
TIDB_OPERATOR = "tidb_operator"
TIFLASH = "tiflash"
TIKV = "tikv"
TISPARK = "tispark"
TIUP = "tiup"
class KnownBugIssue(BaseModel):
known_bug_link: Optional[str] = Field(
description="The github issue tracking the known bug and belongs to the repositories of PingCAP products/components/tools. "
)
affect_tidb_product: TiDBProduct
affect_components: List[TiDBComponent]
affect_versions: List[str] = Field(
description="""The affected versions of the affected components.
- If the problem is caused by a known bug, you can obtain it through the bug issue information from GitHub issue. (For example: `v7.1`, `v7.2`)
- If the issue is not documented, use the versions in the support ticket as the affected version
- If it is difficult to determine, output 'N/A'
- Sort by version number in ascending order
For examples:
- ["v7.1", "v7.2"]
- ["N/A"]
""",
)
fixed_versions: List[str] = Field(
description="""The versions of the products/components/tools that users can upgrade to to fix the bug.
If the problem is caused by a bug issue recorded on GitHub, you can obtain it through the issue information.
For examples:
- ["v7.1.4", "v7.5.1", "v8.0.1"]
- ["N/A"]
""",
)
class KBIssueCase(BaseModel):
caused_by_known_bug: bool = Field(
description="""Whether it is determined to be caused by a known BUG in the conclusion of the problem.
The known BUG usually recorded in the Github issues of the corresponding repositories by PingCAP R&D teams.
"""
)
known_bug: Optional[KnownBugIssue]
description: str = Field(
description="""A description of the general issue case, explaining under what circumstances the same abnormal situation will occur.
- The same issue case may affect multiple versions (For example: The ticket reporter using TiDB v7.1.1, but actually
the issue case may also affects TiDB v7.2, v7.3), so do not only emphasize the special version used by a ticket reporter,
you can clarify the affected scope in the affect versions section later.
"""
)
root_cause: str = Field(
description="""The root cause result in this generic case.
- Refer to draft_root_cause field, or reason and summarize the root cause based on the discussion in ticket_comments
and the content of the BUG issue on GitHub / Jira."""
)
diagnostic_steps: str = Field(
description="""Detailed diagnostic steps for others to clearly determine whether the their problem is match the current issue case.
- Show the minimum steps to reproduce the problem, for example:
- Sample SQL, the minimum table schema and query SQL can reproduce the problem.
- Operation steps, command lines in the code block.
- Describe the evidence that can identify the problem:
- The detailed error logs with necessary stack traces.
- The differences in query results under different circumstances (TiKV vs TiFlash, Index vs Non-Index, etc)
"""
)
resolution: str = Field(
description="""The resolution to resolve the issue completely.
- Written in conjunction with draft_solutions provided by other engineers and information from the context
- If the issue case is caused by a known bug, it usually need to upgrade to the patch versions to fix the problem.
Upgrade TiDB to the [fixed version](#Affect-version).
"""
)
workaround: Optional[str] = Field(
description="""The workaround (optional) to resolve the problem temporarily or avoid exceptions through some methods,
- Written in conjunction with draft_workaround provided by other engineers and analyze the worklog (comments) of the ticket.
- If there is no other way to solve the problem except the resolution, just return `N/A`.
Temporarily disable aggregate function operator pushdown to TiFlash by executing the following SQL statement:
```sql
set tidb_opt_agg_push_down = 0;
```
"""
)
body: str = Field(
description="The body of the knowledge base document that follow the template and knowledge base writing guide."
)
title: str = Field(
description="""The clearly title of the knowledge base document that can help users quickly identify the issue case.
format "[{source_jira_issue_key}] {title}
1. Extract the keywords in the issue description, identity the particularity of the issue case.
2. Try to draft a title and review the title if overly broad.
[TICKET-3787] lightning import error
[TICKET-3787] lightning import error:scan error on column index 3, name "NEXT_GLOBAL_ROW_ID"
[TICKET-2610] TiKV/TiFlash 查询结果不一致
[TICKET-2610] Inconsistent TiKV/TiFlash query results when aggregating UNION result sets
3. Refine the title and generate a final title.
""",
)
labels: list[str] = Field(
description="""The labels should contains the following items:
1. The affect product
2. The affect component(s)
3. The affect versions (using `_` instead of `.`, for example: `v7.1`, `v7.2`)
4. If the issue case is caused by a known issue, add `known_issue` label
"""
)