Skip to content
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

Prevent MoveBucket from moving a bucket across two different db files #671

Merged
merged 1 commit into from
Jan 12, 2024

Conversation

Elbehery
Copy link
Member

@Elbehery Elbehery commented Jan 9, 2024

This PR adds more test to move bucket feature

  • Test moving buckets between two different database files
  • Test moving buckets using two different transactions

Refer to #635 (comment)

cc @ahrtr @fuweid

@Elbehery Elbehery force-pushed the add_move_bucket_protection branch from c1837ee to 82c3487 Compare January 9, 2024 15:26
@ahrtr
Copy link
Member

ahrtr commented Jan 10, 2024

Let's add 3 cases below,

  • The source tx is readonly, the target tx is readwrite; both are for the same db;
  • The source tx is readwrite, and the target tx is readonly; both are for the same db;
  • The source bucket and target bucket are not in the same db.

@ahrtr ahrtr changed the title add more test movebucket Prevent MoveBucket from moving a bucket across two different db files Jan 10, 2024
@ahrtr ahrtr added this to the v1.4.0 milestone Jan 10, 2024
@Elbehery Elbehery force-pushed the add_move_bucket_protection branch 2 times, most recently from c055ad5 to ff0b03b Compare January 10, 2024 21:36
@Elbehery
Copy link
Member Author

Let's add 3 cases below,

  • The source tx is readonly, the target tx is readwrite; both are for the same db;
  • The source tx is readwrite, and the target tx is readonly; both are for the same db;
  • The source bucket and target bucket are not in the same db.

done 👍🏽

@Elbehery Elbehery force-pushed the add_move_bucket_protection branch from ff0b03b to 8f4afad Compare January 10, 2024 21:42
@ahrtr
Copy link
Member

ahrtr commented Jan 11, 2024

@Elbehery
Please take a look at the workflow failure, thx

@Elbehery Elbehery force-pushed the add_move_bucket_protection branch from 8f4afad to b64adb8 Compare January 11, 2024 18:45
@Elbehery
Copy link
Member Author

@Elbehery Please take a look at the workflow failure, thx

fixed .. my bad, forgot to close the second db file :'(

deep apologies

@Elbehery Elbehery force-pushed the add_move_bucket_protection branch from b64adb8 to b96ff9c Compare January 11, 2024 19:43
@Elbehery
Copy link
Member Author

i got it, i used the wrong var to in the defer :'(

@Elbehery Elbehery force-pushed the add_move_bucket_protection branch from b96ff9c to f905652 Compare January 11, 2024 20:23
@Elbehery Elbehery force-pushed the add_move_bucket_protection branch from f905652 to 8d2ef62 Compare January 12, 2024 09:03
@ahrtr
Copy link
Member

ahrtr commented Jan 12, 2024

@Elbehery Please let's try to get this PR merged today before I create the tag 1.4.0-alpha.0

@Elbehery Elbehery force-pushed the add_move_bucket_protection branch from 8d2ef62 to 1e43c74 Compare January 12, 2024 13:36
@Elbehery
Copy link
Member Author

@ahrtr updated & rebased 👍🏽

err = dstDB.Update(func(tx *bbolt.Tx) error {
dstBucket := prepareBuckets(t, tx, dstBucketPath...)
mErr := srcBucket.MoveBucket([]byte(bucketToMove), dstBucket)
require.Equal(t, expectedErr, mErr)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor comment:

Suggested change
require.Equal(t, expectedErr, mErr)
require.Equal(t, errors.ErrDifferentDB, mErr)

srcBucketPath := []string{"sb1", "sb2"}
dstBucketPath := []string{"db1", "db2"}
bucketToMove := "bucketToMove"
expectedErr := errors.ErrDifferentDB
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
expectedErr := errors.ErrDifferentDB

Signed-off-by: Mustafa Elbehery <melbeher@redhat.com>
@Elbehery Elbehery force-pushed the add_move_bucket_protection branch from 1e43c74 to 7555f26 Compare January 12, 2024 13:57
@Elbehery
Copy link
Member Author

@ahrtr updated

Copy link
Member

@ahrtr ahrtr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Thanks

@ahrtr ahrtr merged commit 2c1cba7 into etcd-io:main Jan 12, 2024
16 checks passed
@ahrtr ahrtr removed this from the v1.4.0 milestone Jan 12, 2024
@Elbehery Elbehery deleted the add_move_bucket_protection branch January 12, 2024 20:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants