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

Change file exist exception to runtime exception in PagedDoraWorker #18337

Conversation

voddle
Copy link
Contributor

@voddle voddle commented Oct 30, 2023

What changes are proposed in this pull request?

The RuntimeException(FileAlreadyExistException) changed to AlreadyExistException() in PagedDoraWorker

Why are the changes needed?

RuntimeException(FileAlreadyExistException) seems won't be caught in DoraWorkerClientServiceHandler when convertin it to AlluxioRuntimeException, which willl cause the loss status code

Does this PR introduce any user facing changes?

no

@voddle
Copy link
Contributor Author

voddle commented Oct 30, 2023

Probably all the behaviors that wrap IOException into RuntimeException need to be changed

Copy link
Contributor

@YichuanSun YichuanSun left a comment

Choose a reason for hiding this comment

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

Thanks for your work! You'd better explain clearly. Can AlreadyExistsException be caught in DoraWorkerClientServiceHandler when converting it to AlluxioRuntimeException?

Comment on lines +964 to +965
throw new AlreadyExistsException(String.format("File %s already exists"
+ "but no overwrite flag", path));
Copy link
Contributor

Choose a reason for hiding this comment

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

You should also provide reason literally for other reviewers.

Copy link
Contributor

Choose a reason for hiding this comment

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

The RuntimeException is caught by DoraWorkClientServiceHandler, which is extracted by AlluxioRuntimeException like below.

try {
    ...
    } catch (Exception e) {
      LOG.error(...);
      responseObserver.onError(AlluxioRuntimeException.from(e).toGrpcStatusRuntimeException());
    }

However, it is just a bare java.lang.RuntimeException, so it cannot be caught in AlluxioRuntimeException.from(), so finally the FileAlreadyExistsException becomes a UnknownRuntimeException, it is weird.

Copy link
Contributor

Choose a reason for hiding this comment

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

If we use AlreadyExistsException, which is a child class of AlluxioStatusException, it will be handled in here, So the problem is solved.

Copy link
Contributor

@YichuanSun YichuanSun left a comment

Choose a reason for hiding this comment

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

Leave comments to explain changes🤯.

Comment on lines +964 to +965
throw new AlreadyExistsException(String.format("File %s already exists"
+ "but no overwrite flag", path));
Copy link
Contributor

Choose a reason for hiding this comment

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

The RuntimeException is caught by DoraWorkClientServiceHandler, which is extracted by AlluxioRuntimeException like below.

try {
    ...
    } catch (Exception e) {
      LOG.error(...);
      responseObserver.onError(AlluxioRuntimeException.from(e).toGrpcStatusRuntimeException());
    }

However, it is just a bare java.lang.RuntimeException, so it cannot be caught in AlluxioRuntimeException.from(), so finally the FileAlreadyExistsException becomes a UnknownRuntimeException, it is weird.

Comment on lines +964 to +965
throw new AlreadyExistsException(String.format("File %s already exists"
+ "but no overwrite flag", path));
Copy link
Contributor

Choose a reason for hiding this comment

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

If we use AlreadyExistsException, which is a child class of AlluxioStatusException, it will be handled in here, So the problem is solved.

@@ -51,7 +51,7 @@ public void testMkdirExisting() {
assertEquals(0, mFsShell.run("mkdir", uri.toString()));
assertEquals(-1, mFsShell.run("mkdir", uri.toString()));
assertTrue(
mOutput.toString().contains("UNKNOWN: alluxio.exception.FileAlreadyExistsException"));
mOutput.toString().contains("ALREADY_EXISTS"));
Copy link
Contributor

Choose a reason for hiding this comment

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

If we modify the code above, the output will be something like this: ALREADY_EXISTS: /var/folders/pc/cpgks26x1lvcm03rzrmz06dh0000gn/T/junit9989567262251760026 already exists , it won't be a UNKNOWN Exception, so we have to do this change.

@YichuanSun YichuanSun added the type-bug This issue is about a bug label Nov 9, 2023
Copy link
Contributor

@jiacheliu3 jiacheliu3 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 for the fix

@jiacheliu3
Copy link
Contributor

alluxio-bot, merge this please

@alluxio-bot alluxio-bot merged commit 1852423 into Alluxio:main Nov 9, 2023
12 checks passed
ssz1997 pushed a commit to ssz1997/alluxio that referenced this pull request Dec 15, 2023
### What changes are proposed in this pull request?

The `RuntimeException(FileAlreadyExistException)` changed to `AlreadyExistException()` in `PagedDoraWorker`

### Why are the changes needed?

`RuntimeException(FileAlreadyExistException)` seems won't be caught in `DoraWorkerClientServiceHandler` when convertin it to `AlluxioRuntimeException`, which willl cause the loss status code

### Does this PR introduce any user facing changes?

no

			pr-link: Alluxio#18337
			change-id: cid-9a520c49579847bae6da21302f484ba713eeb4d9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug This issue is about a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants