Skip to content

Commit

Permalink
Merge pull request #28695 from taosdata/main
Browse files Browse the repository at this point in the history
merge: from main to 3.0
  • Loading branch information
guanshengliang authored Nov 8, 2024
2 parents 95b0430 + b0b1a23 commit 9468216
Show file tree
Hide file tree
Showing 47 changed files with 2,651 additions and 63 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,4 @@ version.h
geos_c.h
source/libs/parser/src/sql.c
include/common/ttokenauto.h

!packaging/smokeTest/pytest_require.txt
33 changes: 32 additions & 1 deletion docs/zh/06-advanced/03-stream.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,4 +228,35 @@ PAUSE STREAM [IF EXISTS] stream_name;
RESUME STREAM [IF EXISTS] [IGNORE UNTREATED] stream_name;
```

没有指定 IF EXISTS,如果该 stream 不存在,则报错。如果存在,则恢复流计算。指定了 IF EXISTS,如果 stream 不存在,则返回成功。如果存在,则恢复流计算。如果指定 IGNORE UNTREATED,则恢复流计算时,忽略流计算暂停期间写入的数据。
没有指定 IF EXISTS,如果该 stream 不存在,则报错。如果存在,则恢复流计算。指定了 IF EXISTS,如果 stream 不存在,则返回成功。如果存在,则恢复流计算。如果指定 IGNORE UNTREATED,则恢复流计算时,忽略流计算暂停期间写入的数据。

### 流计算升级故障恢复

升级 TDengine 后,如果流计算不兼容,需要删除流计算,然后重新创建流计算。步骤如下:

1.修改 taos.cfg,添加 disableStream 1

2.重启 taosd。如果启动失败,修改 stream 目录的名称,避免 taosd 启动的时候尝试加载 stream 目录下的流计算数据信息。不使用删除操作避免误操作导致的风险。需要修改的文件夹:$dataDir/vnode/vnode*/tq/stream,$dataDir 指 TDengine 存储数据的目录,在 $dataDir/vnode/ 目录下会有多个类似 vnode1 、vnode2...vnode* 的目录,全部需要修改里面的 tq/stream 目录的名字,改为 tq/stream.bk

3.启动 taos

```sql
drop stream xxxx; ---- xxx 指stream name
flush database stream_source_db; ---- 流计算读取数据的超级表所在的 database
flush database stream_dest_db; ---- 流计算写入数据的超级表所在的 database
```

举例:

```sql
create stream streams1 into test1.streamst as select _wstart, count(a) c1 from test.st interval(1s) ;
drop database streams1;
flush database test;
flush database test1;
```

4.关闭 taosd

5.修改 taos.cfg,去掉 disableStream 1,或将 disableStream 改为 0

6.启动 taosd
1 change: 1 addition & 0 deletions docs/zh/14-reference/03-taos-sql/02-database.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ alter_database_option: {
| KEEP value
| WAL_RETENTION_PERIOD value
| WAL_RETENTION_SIZE value
| MINROWS value
}
```

Expand Down
10 changes: 5 additions & 5 deletions include/common/tanal.h → include/common/tanalytics.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ typedef struct {
int32_t anode;
int32_t urlLen;
char *url;
} SAnalUrl;
} SAnalyticsUrl;

typedef enum {
ANAL_BUF_TYPE_JSON = 0,
Expand All @@ -53,18 +53,18 @@ typedef struct {
TdFilePtr filePtr;
char fileName[TSDB_FILENAME_LEN + 10];
int64_t numOfRows;
} SAnalColBuf;
} SAnalyticsColBuf;

typedef struct {
EAnalBufType bufType;
TdFilePtr filePtr;
char fileName[TSDB_FILENAME_LEN];
int32_t numOfCols;
SAnalColBuf *pCols;
SAnalyticsColBuf *pCols;
} SAnalBuf;

int32_t taosAnalInit();
void taosAnalCleanup();
int32_t taosAnalyticsInit();
void taosAnalyticsCleanup();
SJson *taosAnalSendReqRetJson(const char *url, EAnalHttpType type, SAnalBuf *pBuf);

int32_t taosAnalGetAlgoUrl(const char *algoName, EAnalAlgoType type, char *url, int32_t urlLen);
Expand Down
59 changes: 59 additions & 0 deletions packaging/delete_ref_lock.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import subprocess
import re

# 执行 git fetch 命令并捕获输出
def git_fetch():
result = subprocess.run(['git', 'fetch'], capture_output=True, text=True)
return result

# 解析分支名称
def parse_branch_name_type1(error_output):
# 使用正则表达式匹配 'is at' 前的分支名称
match = re.search(r"error: cannot lock ref '(refs/remotes/origin/[^']+)': is at", error_output)
if match:
return match.group(1)
return None

# 解析第二种错误中的分支名称
def parse_branch_name_type2(error_output):
# 使用正则表达式匹配 'exists' 前的第一个引号内的分支名称
match = re.search(r"'(refs/remotes/origin/[^']+)' exists;", error_output)
if match:
return match.group(1)
return None

# 执行 git update-ref -d 命令
def git_update_ref(branch_name):
if branch_name:
subprocess.run(['git', 'update-ref', '-d', f'{branch_name}'], check=True)

# 解析错误类型并执行相应的修复操作
def handle_error(error_output):
# 错误类型1:本地引用的提交ID与远程不一致
if "is at" in error_output and "but expected" in error_output:
branch_name = parse_branch_name_type1(error_output)
if branch_name:
print(f"Detected error type 1, attempting to delete ref for branch: {branch_name}")
git_update_ref(branch_name)
else:
print("Error parsing branch name for type 1.")
# 错误类型2:尝试创建新的远程引用时,本地已经存在同名的引用
elif "exists; cannot create" in error_output:
branch_name = parse_branch_name_type2(error_output)
if branch_name:
print(f"Detected error type 2, attempting to delete ref for branch: {branch_name}")
git_update_ref(branch_name)
else:
print("Error parsing branch name for type 2.")

# 主函数
def main():
fetch_result = git_fetch()
if fetch_result.returncode != 0: # 如果 git fetch 命令失败
error_output = fetch_result.stderr
handle_error(error_output)
else:
print("Git fetch successful.")

if __name__ == "__main__":
main()
Loading

0 comments on commit 9468216

Please sign in to comment.