Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
884e7fe6
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
884e7fe6
编写于
4月 27, 2020
作者:
S
Steven Li
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Recreated the tscServer.c:312 crash
上级
dc2b3437
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
17 addition
and
15 deletion
+17
-15
tests/pytest/random_walk.py
tests/pytest/random_walk.py
+17
-15
未找到文件。
tests/pytest/random_walk.py
浏览文件 @
884e7fe6
...
...
@@ -283,20 +283,20 @@ class LinearQueue():
return
0
return
self
.
pop
()
def
us
e
(
self
,
i
):
def
allocat
e
(
self
,
i
):
with
self
.
lock
:
if
(
i
in
self
.
inUse
):
raise
RuntimeError
(
"Cannot re-use same index in queue: {}"
.
format
(
i
))
self
.
inUse
.
add
(
i
)
def
unU
se
(
self
,
i
):
def
relea
se
(
self
,
i
):
with
self
.
lock
:
self
.
inUse
.
remove
(
i
)
# KeyError possible
def
size
(
self
):
return
self
.
lastIndex
+
1
-
self
.
firstIndex
def
a
llocate
(
self
):
def
pickAndA
llocate
(
self
):
with
self
.
lock
:
cnt
=
0
# counting the interations
while
True
:
...
...
@@ -305,7 +305,7 @@ class LinearQueue():
raise
RuntimeError
(
"Failed to allocate LinearQueue element"
)
ret
=
Dice
.
throwRange
(
self
.
firstIndex
,
self
.
lastIndex
+
1
)
if
(
not
ret
in
self
.
inUse
):
return
self
.
us
e
(
ret
)
return
self
.
allocat
e
(
ret
)
# State of the database as we believe it to be
...
...
@@ -317,8 +317,12 @@ class DbState():
self
.
openDbServerConnection
()
self
.
lock
=
threading
.
RLock
()
def
pickTable
(
self
):
# pick any table, and "use" it
return
self
.
tableNumQueue
.
allocate
()
def
pickAndAllocateTable
(
self
):
# pick any table, and "use" it
return
self
.
tableNumQueue
.
pickAndAllocate
()
def
releaseTable
(
self
,
i
):
# return the table back, so others can use it
self
.
tableNumQueue
.
release
(
i
)
def
getNextTick
(
self
):
with
self
.
lock
:
# prevent duplicate tick
...
...
@@ -330,9 +334,6 @@ class DbState():
self
.
int
+=
1
return
self
.
int
def
unuseTable
(
self
,
i
):
# return the table back, so others can use it
self
.
tableNumQueue
.
unUse
(
i
)
def
openDbServerConnection
(
self
):
cfgPath
=
"../../build/test/cfg"
# was: tdDnodes.getSimCfgPath()
conn
=
taos
.
connect
(
host
=
"127.0.0.1"
,
config
=
cfgPath
)
# TODO: make configurable
...
...
@@ -380,9 +381,10 @@ class DropTableTask(Task):
class
AddDataTask
(
Task
):
def
execute
(
self
):
logger
.
info
(
" Adding some data..."
)
# ds = self.dbState
# tIndex = self.dbState.pickTable()
# tdSql.execute("insert into table_{} values ('{}', {});".format(tIndex, ds.getNextTick(), ds.getNextInt()))
ds
=
self
.
dbState
tIndex
=
ds
.
pickTable
()
tdSql
.
execute
(
"insert into table_{} values ('{}', {});"
.
format
(
tIndex
,
ds
.
getNextTick
(),
ds
.
getNextInt
()))
ds
.
r
# Deterministic random number generator
class
Dice
():
...
...
@@ -423,8 +425,8 @@ class WorkDispatcher():
# self.totalNumMethods = 2
self
.
tasks
=
[
CreateTableTask
(
dbState
),
DropTableTask
(
dbState
),
#
AddDataTask(dbState),
#
DropTableTask(dbState),
AddDataTask
(
dbState
),
]
def
throwDice
(
self
):
...
...
@@ -443,7 +445,7 @@ if __name__ == "__main__":
Dice
.
seed
(
0
)
# initial seeding of dice
dbState
=
DbState
()
threadPool
=
SteppingThreadPool
(
dbState
,
3
,
5
,
0
)
threadPool
=
SteppingThreadPool
(
dbState
,
1
,
5
,
0
)
threadPool
.
run
()
logger
.
info
(
"Finished running thread pool"
)
dbState
.
closeDbServerConnection
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录