Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
plugin
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
link33
plugin
Commits
314762f8
Commit
314762f8
authored
Jun 22, 2019
by
liuyuhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改一次迭代为多次迭代删除数据,该方法删除,空间不会有较大波动,但是删除速度非常忙
parent
0667b077
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
8 deletions
+41
-8
kvmvcc_mavl.go
plugin/store/kvmvccmavl/kvmvcc_mavl.go
+41
-8
No files found.
plugin/store/kvmvccmavl/kvmvcc_mavl.go
View file @
314762f8
...
...
@@ -367,6 +367,8 @@ func delMavlData(db dbm.DB) bool {
it
:=
db
.
Iterator
(
nil
,
nil
,
true
)
defer
it
.
Close
()
batch
:=
db
.
NewBatch
(
true
)
count
:=
0
const
onceCount
=
200
for
it
.
Rewind
();
it
.
Valid
();
it
.
Next
()
{
if
quit
{
return
false
...
...
@@ -376,9 +378,13 @@ func delMavlData(db dbm.DB) bool {
if
batch
.
ValueSize
()
>
batchDataSize
{
dbm
.
MustWrite
(
batch
)
batch
.
Reset
()
time
.
Sleep
(
time
.
Millisecond
*
500
)
time
.
Sleep
(
time
.
Millisecond
*
100
)
count
++
}
}
if
count
>
onceCount
{
return
false
}
}
batch
.
Set
(
genDelMavlKey
(
mvccPrefix
),
[]
byte
(
""
))
dbm
.
MustWrite
(
batch
)
...
...
@@ -424,28 +430,55 @@ func deletePrunedMavl(db dbm.DB) {
setDelPrunedMavl
(
delPrunedMavlStarting
)
defer
setDelPrunedMavl
(
delPruneMavlEnd
)
deletePrunedMavlData
(
db
,
hashNodePrefix
)
deletePrunedMavlData
(
db
,
leafNodePrefix
)
deletePrunedMavlData
(
db
,
leafKeyCountPrefix
)
deletePrunedMavlData
(
db
,
oldLeafKeyCountPrefix
)
for
{
loop
:=
deletePrunedMavlData
(
db
,
hashNodePrefix
)
if
!
loop
{
break
}
}
for
{
loop
:=
deletePrunedMavlData
(
db
,
leafNodePrefix
)
if
!
loop
{
break
}
}
for
{
loop
:=
deletePrunedMavlData
(
db
,
leafKeyCountPrefix
)
if
!
loop
{
break
}
}
for
{
loop
:=
deletePrunedMavlData
(
db
,
oldLeafKeyCountPrefix
)
if
!
loop
{
break
}
}
}
func
deletePrunedMavlData
(
db
dbm
.
DB
,
prefix
string
)
{
func
deletePrunedMavlData
(
db
dbm
.
DB
,
prefix
string
)
(
loop
bool
)
{
it
:=
db
.
Iterator
([]
byte
(
prefix
),
nil
,
true
)
defer
it
.
Close
()
count
:=
0
const
onceCount
=
200
if
it
.
Rewind
()
&&
it
.
Valid
()
{
batch
:=
db
.
NewBatch
(
false
)
for
it
.
Next
();
it
.
Valid
();
it
.
Next
()
{
//第一个不做删除
if
quit
{
return
return
false
}
batch
.
Delete
(
it
.
Key
())
if
batch
.
ValueSize
()
>
batchDataSize
{
dbm
.
MustWrite
(
batch
)
batch
.
Reset
()
time
.
Sleep
(
time
.
Millisecond
*
500
)
time
.
Sleep
(
time
.
Millisecond
*
100
)
count
++
}
if
count
>
onceCount
{
return
true
}
}
dbm
.
MustWrite
(
batch
)
}
return
false
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment