Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lzh_me
TDengine
提交
dcb11554
TDengine
项目概览
lzh_me
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
dcb11554
编写于
5月 08, 2020
作者:
S
Steven Li
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Discovered TD-256 with params: -p -d -t 10 -s 20
上级
6623cb63
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
39 addition
and
11 deletion
+39
-11
tests/pytest/crash_gen.py
tests/pytest/crash_gen.py
+39
-11
未找到文件。
tests/pytest/crash_gen.py
浏览文件 @
dcb11554
...
...
@@ -136,11 +136,17 @@ class WorkerThread:
self
.
_stepGate
.
set
()
# wake up!
time
.
sleep
(
0
)
# let the released thread run a bit
def
execSql
(
self
,
sql
):
def
execSql
(
self
,
sql
):
# not "execute", since we are out side the DB context
if
(
gConfig
.
per_thread_db_connection
):
return
self
.
_dbConn
.
execute
(
sql
)
else
:
return
self
.
_tc
.
getDbState
.
getDbConn
().
execute
(
sql
)
def
querySql
(
self
,
sql
):
# not "execute", since we are out side the DB context
if
(
gConfig
.
per_thread_db_connection
):
return
self
.
_dbConn
.
execSql
(
sql
)
return
self
.
_dbConn
.
query
(
sql
)
else
:
return
self
.
_tc
.
getDbState
.
getDbConn
().
execSql
(
sql
)
return
self
.
_tc
.
getDbState
.
getDbConn
().
query
(
sql
)
class
ThreadCoordinator
:
def
__init__
(
self
,
pool
,
wd
:
WorkDispatcher
,
dbState
):
...
...
@@ -380,11 +386,17 @@ class DbConn:
self
.
_tdSql
.
close
()
self
.
isOpen
=
False
def
exec
Sql
(
self
,
sql
):
def
exec
ute
(
self
,
sql
):
if
(
not
self
.
isOpen
):
raise
RuntimeError
(
"Cannot
query database
until connection is open"
)
raise
RuntimeError
(
"Cannot
execute database commands
until connection is open"
)
return
self
.
_tdSql
.
execute
(
sql
)
def
query
(
self
,
sql
)
->
int
:
# return number of rows retrieved
if
(
not
self
.
isOpen
):
raise
RuntimeError
(
"Cannot query database until connection is open"
)
return
self
.
_tdSql
.
query
(
sql
)
# State of the database as we believe it to be
class
DbState
():
STATE_INVALID
=
-
1
...
...
@@ -441,27 +453,36 @@ class DbState():
return
"table_{}"
.
format
(
tblNum
)
def
execSql
(
self
,
sql
):
# using the main DB connection
return
self
.
_dbConn
.
exec
Sql
(
sql
)
return
self
.
_dbConn
.
exec
ute
(
sql
)
def
cleanUp
(
self
):
self
.
_dbConn
.
close
()
def
getTasksAtState
(
self
):
tasks
=
[]
tasks
.
append
(
ReadFixedDataTask
(
self
))
# always
if
(
self
.
_state
==
self
.
STATE_EMPTY
):
return
[
CreateDbTask
(
self
),
CreateFixedTableTask
(
self
)]
tasks
.
append
(
CreateDbTask
(
self
))
tasks
.
append
(
CreateFixedTableTask
(
self
))
elif
(
self
.
_state
==
self
.
STATE_DB_ONLY
):
return
[
DropDbTask
(
self
),
CreateFixedTableTask
(
self
),
AddFixedDataTask
(
self
)]
tasks
.
append
(
DropDbTask
(
self
))
tasks
.
append
(
CreateFixedTableTask
(
self
))
tasks
.
append
(
AddFixedDataTask
(
self
))
elif
(
self
.
_state
==
self
.
STATE_TABLE_ONLY
):
return
[
DropFixedTableTask
(
self
),
AddFixedDataTask
(
self
)]
tasks
.
append
(
DropFixedTableTask
(
self
))
tasks
.
append
(
AddFixedDataTask
(
self
))
elif
(
self
.
_state
==
self
.
STATE_HAS_DATA
)
:
# same as above. TODO: adjust
return
[
DropFixedTableTask
(
self
),
AddFixedDataTask
(
self
)]
tasks
.
append
(
DropFixedTableTask
(
self
))
tasks
.
append
(
AddFixedDataTask
(
self
))
else
:
raise
RuntimeError
(
"Unexpected DbState state: {}"
.
format
(
self
.
_state
))
return
tasks
def
transition
(
self
,
tasks
):
if
(
len
(
tasks
)
==
0
):
# before 1st step, or otherwise empty
return
# do nothing
if
(
self
.
_state
==
self
.
STATE_EMPTY
):
# self.assertNoSuccess(tasks, ReadFixedDataTask) # some read may be successful, since we might be creating a table
if
(
self
.
hasSuccess
(
tasks
,
CreateDbTask
)
):
self
.
assertAtMostOneSuccess
(
tasks
,
CreateDbTask
)
# param is class
self
.
_state
=
self
.
STATE_DB_ONLY
...
...
@@ -504,7 +525,7 @@ class DbState():
else
:
# did not drop table, did not insert data, that is impossible
raise
RuntimeError
(
"Unexpected no-success scenarios"
)
elif
(
self
.
_state
==
self
.
STATE_
TABLE_ONLY
):
# Same as above, TODO: adjust
elif
(
self
.
_state
==
self
.
STATE_
HAS_DATA
):
# Same as above, TODO: adjust
if
(
self
.
hasSuccess
(
tasks
,
DropFixedTableTask
)
):
self
.
assertAtMostOneSuccess
(
tasks
,
DropFixedTableTask
)
self
.
_state
=
self
.
STATE_DB_ONLY
...
...
@@ -589,6 +610,7 @@ class Task():
self
.
_workerThread
=
None
self
.
_err
=
None
self
.
_curStep
=
None
self
.
_numRows
=
None
# Number of rows affected
# Assign an incremental task serial number
self
.
_taskNum
=
self
.
allocTaskNum
()
...
...
@@ -653,6 +675,12 @@ class CreateFixedTableTask(Task):
tblName
=
self
.
_dbState
.
getFixedTableName
()
wt
.
execSql
(
"create table db.{} (ts timestamp, speed int)"
.
format
(
tblName
))
class
ReadFixedDataTask
(
Task
):
def
_executeInternal
(
self
,
te
:
TaskExecutor
,
wt
:
WorkerThread
):
tblName
=
self
.
_dbState
.
getFixedTableName
()
self
.
_numRows
=
wt
.
querySql
(
"select * from db.{}"
.
format
(
tblName
))
# save the result for later
# tdSql.query(" cars where tbname in ('carzero', 'carone')")
class
DropTableTask
(
Task
):
def
_executeInternal
(
self
,
te
:
TaskExecutor
,
wt
:
WorkerThread
):
tableName
=
self
.
_dbState
.
getTableNameToDelete
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录