Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
djrandom
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
ale
djrandom
Commits
3665fee3
Commit
3665fee3
authored
10 years ago
by
ale
Browse files
Options
Downloads
Patches
Plain Diff
try to perform backups without killing the server
parent
b188f6f9
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
services/database/backuptool/backuptool.go
+29
-13
29 additions, 13 deletions
services/database/backuptool/backuptool.go
with
29 additions
and
13 deletions
services/database/backuptool/backuptool.go
+
29
−
13
View file @
3665fee3
...
...
@@ -84,12 +84,18 @@ func scanner(db *db_client.DatabaseRpcClient, bucketCh chan string, outCh chan R
defer
session
.
Close
()
for
bucket
:=
range
bucketCh
{
iter
,
err
:=
session
.
Scan
(
bucket
,
""
,
"
\xff
"
,
-
1
)
// Call Scan() in batches, to avoid overloading the server.
batchSize
:=
1000
startKey
,
endKey
:=
""
,
"
\xff
"
for
startKey
<
endKey
{
iter
,
err
:=
session
.
Scan
(
bucket
,
startKey
,
endKey
,
batchSize
)
if
err
!=
nil
{
log
.
Printf
(
"Scan error for bucket %s: %s"
,
bucket
,
err
)
continue
break
}
// Iterate over the results and send them to outCh.
n
:=
0
for
{
var
data
[]
byte
key
,
err
:=
iter
.
Next
(
&
data
)
...
...
@@ -102,6 +108,16 @@ func scanner(db *db_client.DatabaseRpcClient, bucketCh chan string, outCh chan R
Key
:
key
,
Data
:
data
,
}
n
++
startKey
=
key
}
// An empty result means we've reached the end
// of the scan.
if
n
==
0
{
break
}
// Start the next scan from the next key.
startKey
=
db_client
.
IncrementKey
(
startKey
)
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment