Skip to content

Conversation

@vrinda-db
Copy link
Collaborator

@vrinda-db vrinda-db commented Aug 13, 2025

In this PR

  • we add a new integer field httpStatusErrorCode in EndStreamAction in both client/model and server/model.
  • In the client, if httpStatusErrorCode is present and it represents a retryable error code we retry the request to the server.

We already retry based on the http status code of the http request but not based on the status code of errors that happen after the header/status code has been sent. This retry is being added here. The way that it is being implemented is by making both the cases extend the same base exception class DeltaSharingExceptionWithErrorCode.

Added unit tests for the changes.

@vrinda-db vrinda-db marked this pull request as ready for review August 13, 2025 17:37
s"with error message ${lastEndStreamAction.errorMessage}")
throw new DeltaSharingServerException(
s"Server Exception: ${lastEndStreamAction.errorMessage}",
Option(lastEndStreamAction.httpStatusErrorCode).map(_.intValue))
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit question: is it better to put error code in front?

Copy link
Collaborator Author

@vrinda-db vrinda-db Aug 13, 2025

Choose a reason for hiding this comment

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

Do you mean in the error message? Would it be useful?

Copy link
Collaborator

Choose a reason for hiding this comment

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

To me, errorCode is more abstracted and quick glance of what's happening.

Also, do we know what's the user facing error with this new definition of DeltaSharingServerException? do they see the errorCode? it could also be helpful for debugging.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Right now, no I don't think the errorCode will be showing in the error message since we are not overriding any of the default converters from the RuntimeException class.

I pushed a change to pre-pend the error message with the status code.

Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: L1372 can use errorCodeOpt

Copy link
Collaborator

Choose a reason for hiding this comment

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

And also nit UX: Does "Server Exception500" look good?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

resolved!

@vrinda-db vrinda-db requested a review from linzhou-db August 13, 2025 20:42
s"with error message ${lastEndStreamAction.errorMessage}")
throw new DeltaSharingServerException(
s"Server Exception: ${lastEndStreamAction.errorMessage}",
Option(lastEndStreamAction.httpStatusErrorCode).map(_.intValue))
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: L1372 can use errorCodeOpt

s"with error message ${lastEndStreamAction.errorMessage}")
throw new DeltaSharingServerException(
s"Server Exception: ${lastEndStreamAction.errorMessage}",
Option(lastEndStreamAction.httpStatusErrorCode).map(_.intValue))
Copy link
Collaborator

Choose a reason for hiding this comment

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

And also nit UX: Does "Server Exception500" look good?

Copy link
Collaborator

@littlegrasscao littlegrasscao left a comment

Choose a reason for hiding this comment

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

The change itself looks good.

After this code change, getFile could run longer than before. In a streaming query, it’s possible to have multiple getBatch calls to DeltaSharingDatasource. I’m wondering whether we need to make maybeGetFileChanges thread-safe within a datasource.
@linzhou-db

s"with error message ${lastEndStreamAction.errorMessage}")
val errorCodeOpt = Option(lastEndStreamAction.httpStatusErrorCode).map(_.intValue)
throw new DeltaSharingServerException(
s"Server Exception${errorCodeOpt.getOrElse("")}: " +
Copy link
Collaborator

Choose a reason for hiding this comment

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

Server Exception[${...}]?

@linzhou-db
Copy link
Collaborator

linzhou-db commented Aug 13, 2025

After this code change, getFile could run longer than before. In a streaming query, it’s possible to have multiple getBatch calls to DeltaSharingDatasource. I’m wondering whether we need to make maybeGetFileChanges thread-safe within a datasource.

Hmmm, good point, what's the consequence if not? @littlegrasscao

@vrinda-db vrinda-db merged commit b33530c into main Aug 13, 2025
7 checks passed
@littlegrasscao
Copy link
Collaborator

After this code change, getFile could run longer than before. In a streaming query, it’s possible to have multiple getBatch calls to DeltaSharingDatasource. I’m wondering whether we need to make maybeGetFileChanges thread-safe within a datasource.

Hmmm, good point, what's the consequence if not? @littlegrasscao

@linzhou-db

  1. Multiple queryTable requests are sent to the server in parallel.
  2. In-memory sorted files can get overwritten. Reading earlier versions could result in empty results if getBatch encounters a race condition.

I guess these issues could happen today if multiple getBatch calls occur and queryTable from version a to b runs for a long time. So far, we haven’t seen any issues, right?

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

Successfully merging this pull request may close these issues.

4 participants