-
Notifications
You must be signed in to change notification settings - Fork 665
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add MoveBucket to support moving a sub-bucket from one bucket to anot… #635
Conversation
5157812
to
f17b5b9
Compare
9c40fa4
to
795773d
Compare
@ahrtr to follow up on testing this and according to #625 (comment) i can use
to generate random keys & values .. also can generate random bucket depth and large keys & values as requested would this be ok ? |
also @fuweid suggested #625 (comment) this is another direction, please let me know |
795773d
to
4ba996b
Compare
2764772
to
1104182
Compare
bca8641
to
dd2df9e
Compare
The test case is big enough, suggest to get all MoveBucket related test cases defined in a separate file e.g. |
b1b529d
to
366b123
Compare
I separated the test into a separate file i am stuck with dumping the bucket content into a file and comparing it, i will tag you on the code |
I see that some tests are still in tx_test.go. Please get all moveBucket related test cases included in the new file. |
491ab6b
to
1e7d3a0
Compare
the failing test is not related to this change
|
|
@ahrtr it is the cleanUp on Windows :/
|
this should have been fixed in golang/go#50051 the fix is retrying to remove using this
two option, either I fall back to |
Note that we have lots of usage of |
movebucket_test.go
Outdated
} | ||
} | ||
|
||
func createBucketIfNotExist(t testing.TB, tx *bbolt.Tx, incompatibleKey bool, paths ...string) *bbolt.Bucket { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the example in #635 (comment), the parameter paths
should be [sb1, sb2] or [db1, db2]
func createBucketIfNotExist(t testing.TB, tx *bbolt.Tx, incompatibleKey bool, paths ...string) *bbolt.Bucket { | |
func openBuckets(t testing.TB, tx *bbolt.Tx, paths ...string) *bbolt.Bucket { |
The high level algorithm is something like below,
- Create the bucket hirarchy structure
- if incompatibleKeyInSrc is true, then create a normal key; otherwise, create a sub-bucket
- the same thing for the incompatibleKeyInDst
- Move the bucket
- open the bucket: reuse
openBuckets
- call tx.MoveBucket(key, srcBucket, dstBucket)
- open the bucket: reuse
- Verify
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
33bcf3b
to
8e38c33
Compare
yes i see many times in the code it uses it exactly as I do
i really dont know why it fails now, the issue is |
35594d2
to
19878bf
Compare
…her bucket Signed-off-by: Benjamin Wang <benjamin.ahrtr@gmail.com>
Signed-off-by: Mustafa Elbehery <melbeher@redhat.com>
19878bf
to
ac355de
Compare
Signed-off-by: Benjamin Wang <benjamin.ahrtr@gmail.com>
b8bb918
to
0bd26bc
Compare
3f5ac39
to
57ba37e
Compare
Signed-off-by: Benjamin Wang <benjamin.ahrtr@gmail.com>
57ba37e
to
886eccb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
} | ||
}() | ||
|
||
if b.tx.db == nil || dstBucket.tx.db == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like we should limit both src and dst are in that same db.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, it's a good point.
We can add protection something like below in (*Bucket)MoveBucket
,
if b.tx.db.Path() != dstBucket.tx.db.Path() || b.tx != dstBucket.tx {
// return error
}
We also need to add a test
@Elbehery can you take care of it in a following up PR?
This PR is a replacement to #625
cc @ahrtr @fuweid