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

Synchronisation issues #1737

Closed
alebastrov opened this issue Mar 22, 2024 · 6 comments
Closed

Synchronisation issues #1737

alebastrov opened this issue Mar 22, 2024 · 6 comments
Assignees

Comments

@alebastrov
Copy link

alebastrov commented Mar 22, 2024

  1. createBucket & loadBuckets methods - vulnerability time gap
lockStore.putIfAbsent(bucketName, new Object());
synchronized (lockStore.get(bucketName)) ...

there SHOULD be

var newObj = new Object();
var obj = lockStore.putIfAbsent(bucketName, newObj);
synchronized (obj == null ? newObj : obj) ...
  1. var bucketMetadata = getBucketMetadata(bucketName); method is being called from sync and out of sync code which is weird, I'd call this method in all places FROM synchronization block

  2. putObject - 2 operations (check + create) with 'bucketMetadata' leads to vulnerability time gap but they (couple of operations) entirely should be atomic (check&create at once)

var bucketMetadata = bucketStore.getBucketMetadata(bucketName);
    var id = bucketMetadata.getID(key);
    if (id == null) {
      id = bucketStore.addToBucket(key, bucketName);
    }

consider of replacing them to atomic 'addIfAbsent(key, bucketName)' - in bucketStore it should be sync method

  1. deleteObject -the same as 3) - bucketStore - get/remove should be atomic
    var bucketMetadata = bucketStore.getBucketMetadata(bucketName);
    var id = bucketMetadata.getID(key);
    if (id == null) {
      return false;
    }

    if (objectStore.deleteObject(bucketMetadata, id)) {
      return bucketStore.removeFromBucket(key, bucketName);
    } else {
      return false;
    }

it's better to replace them to 'deleteIfExist(bucketName, id)'

  1. other methods in ObjectService, like setObjectTags/copyS3Object/putS3Object/setObjectTags/setLegalHold etc
@afranken afranken self-assigned this Apr 3, 2024
@afranken
Copy link
Member

afranken commented May 4, 2024

@alebastrov
thanks for looking at ways to improve our code.

This application is not meant to be used with massive parallel requests manipulating the same objects or buckets, but for integration testing services.

APIs like setLegalHold and others would only fail if the object is deleted while the API is being called.
Again, this is meant for testing your service against a local mock of S3. Not sure why your integration test would delete objects or buckets while manipulating them with another connection...

@alebastrov
Copy link
Author

Our tests are based on idea that some thread puts object to s3, another one reads/verifies whether it exists. Sometimes that scenario fails due to illegal response - object does not exist or put object on s3 fails

@afranken
Copy link
Member

are the threads putting / modifying the same resources over and over?
What is the actual use-case for this?

@alebastrov
Copy link
Author

alebastrov commented Jul 18, 2024

yep. resources names are always the same and issue appears when NO parallel requests are coming

@afranken
Copy link
Member

yep. resources names are always the same and issue appears when NO parallel requests are coming

please provide a reproducer for this.
There are integration-tests passing on every commit that concurrently modify resources and buckets.

@afranken
Copy link
Member

afranken commented Oct 4, 2024

closing for lack of activity and evidence.

@afranken afranken closed this as completed Oct 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants