Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-ds-badger
Commits
78c54b53
Commit
78c54b53
authored
Oct 09, 2020
by
gammazero
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Log error if batch not committed or canceled
parent
8a4303f9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
2 deletions
+8
-2
datastore.go
datastore.go
+8
-2
No files found.
datastore.go
View file @
78c54b53
...
...
@@ -409,7 +409,10 @@ func (d *Datastore) Batch() (ds.Batch, error) {
b
:=
&
batch
{
d
,
d
.
DB
.
NewWriteBatch
()}
// Ensure that incomplete transaction resources are cleaned up in case
// batch is abandoned.
runtime
.
SetFinalizer
(
b
,
func
(
b
*
batch
)
{
b
.
cancel
()
})
runtime
.
SetFinalizer
(
b
,
func
(
b
*
batch
)
{
b
.
cancel
()
log
.
Error
(
"batch not committed or canceled"
)
})
return
b
,
nil
}
...
...
@@ -481,8 +484,10 @@ func (b *batch) commit() error {
if
err
!=
nil
{
// Discard incomplete transaction held by b.writeBatch
b
.
cancel
()
return
err
}
return
err
runtime
.
SetFinalizer
(
b
,
nil
)
return
nil
}
func
(
b
*
batch
)
Cancel
()
error
{
...
...
@@ -498,6 +503,7 @@ func (b *batch) Cancel() error {
func
(
b
*
batch
)
cancel
()
{
b
.
writeBatch
.
Cancel
()
runtime
.
SetFinalizer
(
b
,
nil
)
}
var
_
ds
.
Datastore
=
(
*
txn
)(
nil
)
...
...
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