Skip to content

#165: Make YdbValidator implementation customizable via YdbRepository settings - #238

Open
nvamelichev wants to merge 1 commit into
mainfrom
pluggable-YdbValidator
Open

nvamelichev wants to merge 1 commit into
mainfrom
pluggable-YdbValidator

Conversation

@nvamelichev

Copy link
Copy Markdown
Collaborator

This opens the door for error handling customization that can work without changing the core error handling logic in repository-ydb-v2.

@nvamelichev
nvamelichev requested a review from lavrukov June 7, 2026 00:17
@nvamelichev nvamelichev self-assigned this Jun 7, 2026
@nvamelichev nvamelichev added feature New feature or request experimental labels Jun 7, 2026
@nvamelichev nvamelichev linked an issue Jun 7, 2026 that may be closed by this pull request
@github-actions

github-actions Bot commented Jun 7, 2026

Copy link
Copy Markdown
Overall Project 55% -0.27% 🍏
Files changed 71.88% 🍏

Module Coverage
YOJ - YDB Repository (SDK v2.x) 75.6% -0.6% 🍏
Files
Module File Coverage
YOJ - YDB Repository (SDK v2.x) YdbValidator.java 100% 🍏
YdbSpliterator.java 90.48% 🍏
YdbRepositoryTransaction.java 79.94% 🍏
SessionClient.java 79.49% 🍏
YdbRepository.java 70.48% 🍏
YdbValidatorImpl.java 67.77% -32.23% 🍏
YdbOperations.java 44.83% -22.41% ❌
YdbSessionManager.java 43.2% -15.2% 🍏

@nvamelichev
nvamelichev force-pushed the pluggable-YdbValidator branch from e2e84dc to 507f414 Compare June 7, 2026 00:21
@github-actions

github-actions Bot commented Jun 7, 2026

Copy link
Copy Markdown
Overall Project 55% -0.27% 🍏
Files changed 71.88% 🍏

Module Coverage
YOJ - YDB Repository (SDK v2.x) 75.6% -0.6% 🍏
Files
Module File Coverage
YOJ - YDB Repository (SDK v2.x) YdbValidator.java 100% 🍏
YdbSpliterator.java 90.48% 🍏
YdbRepositoryTransaction.java 79.94% 🍏
SessionClient.java 79.49% 🍏
YdbRepository.java 70.48% 🍏
YdbValidatorImpl.java 67.77% -32.23% 🍏
YdbOperations.java 44.83% -22.41% ❌
YdbSessionManager.java 43.2% -15.2% 🍏

@nvamelichev
nvamelichev force-pushed the pluggable-YdbValidator branch from 507f414 to d680458 Compare June 7, 2026 00:26
@github-actions

github-actions Bot commented Jun 7, 2026

Copy link
Copy Markdown
Overall Project 55% -0.27% 🍏
Files changed 71.88% 🍏

Module Coverage
YOJ - YDB Repository (SDK v2.x) 75.6% -0.6% 🍏
Files
Module File Coverage
YOJ - YDB Repository (SDK v2.x) YdbValidator.java 100% 🍏
YdbSpliterator.java 90.48% 🍏
YdbRepositoryTransaction.java 79.94% 🍏
SessionClient.java 79.49% 🍏
YdbRepository.java 70.48% 🍏
YdbValidatorImpl.java 67.77% -32.23% 🍏
YdbOperations.java 44.83% -22.41% ❌
YdbSessionManager.java 43.2% -15.2% 🍏

@nvamelichev
nvamelichev force-pushed the pluggable-YdbValidator branch from d680458 to 8c05118 Compare October 2, 2026 12:04
@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown
Overall Project 55.28% -0.27% 🍏
Files changed 71.88% 🍏

Module Coverage
YOJ - YDB Repository (SDK v2.x) 75.62% -0.6% 🍏
Files
Module File Coverage
YOJ - YDB Repository (SDK v2.x) YdbValidator.java 100% 🍏
YdbSpliterator.java 90.48% 🍏
YdbRepositoryTransaction.java 79.94% 🍏
SessionClient.java 79.49% 🍏
YdbRepository.java 70.48% 🍏
YdbValidatorClassic.java 67.77% -32.23% 🍏
YdbOperations.java 44.83% -22.41% ❌
YdbSessionManager.java 43.2% -15.2% 🍏

@nvamelichev
nvamelichev force-pushed the pluggable-YdbValidator branch from 8c05118 to 0547c6f Compare October 2, 2026 12:14
@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown
Overall Project 55.28% -0.31% 🍏
Files changed 68.76% 🍏

Module Coverage
YOJ - YDB Repository (SDK v2.x) 75.62% -0.7% 🍏
Files
Module File Coverage
YOJ - YDB Repository (SDK v2.x) YdbSpliterator.java 90.48% 🍏
YdbRepositoryTransaction.java 79.94% 🍏
SessionClient.java 79.49% 🍏
YdbRepository.java 70.48% 🍏
YdbValidatorClassic.java 67.77% -32.23% 🍏
YdbOperations.java 53.09% -25.93% ❌
YdbSessionManager.java 43.2% -15.2% 🍏
YdbValidator.java 31.58% -68.42% ❌

@nvamelichev
nvamelichev force-pushed the pluggable-YdbValidator branch from 0547c6f to 9cd9918 Compare October 2, 2026 12:57
@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown
Overall Project 55.29% -0.31% 🍏
Files changed 68.76% 🍏

Module Coverage
YOJ - YDB Repository (SDK v2.x) 75.62% -0.7% 🍏
Files
Module File Coverage
YOJ - YDB Repository (SDK v2.x) YdbSpliterator.java 90.48% 🍏
YdbRepositoryTransaction.java 79.94% 🍏
SessionClient.java 79.49% 🍏
YdbRepository.java 70.48% 🍏
YdbValidatorClassic.java 67.77% -32.23% 🍏
YdbOperations.java 53.09% -25.93% ❌
YdbSessionManager.java 43.2% -15.2% 🍏
YdbValidator.java 31.58% -68.42% ❌

@nvamelichev

Copy link
Copy Markdown
Collaborator Author

@lavrukov Gentle ping: Please take a look at this PR, I'd like to include it in the next release of YOJ ;-)

@nvamelichev
nvamelichev force-pushed the pluggable-YdbValidator branch from 9cd9918 to 299adc1 Compare November 5, 2026 22:13
@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown
Overall Project 55.1% -0.96% 🍏
Files changed 60.54% 🍏

Module Coverage
YOJ - In-Memory Repository 85.88% 🍏
YOJ - YDB Repository (SDK v2.x) 75.55% -1.14% 🍏
YOJ - Repository API 23.65% -2.07% ❌
Files
Module File Coverage
YOJ - In-Memory Repository InMemoryRepositoryTransaction.java 96.73% 🍏
InMemoryTable.java 88.81% 🍏
YOJ - YDB Repository (SDK v2.x) YdbSpliterator.java 90.48% 🍏
YdbRepositoryTransaction.java 79.65% -3.87% 🍏
SessionClient.java 79.49% 🍏
YdbRepository.java 71.2% 🍏
FindStatement.java 71.03% 🍏
YdbValidatorClassic.java 64.05% -35.95% 🍏
YdbSessionManager.java 50.47% -16.82% 🍏
YdbOperations.java 42.64% -36.43% ❌
YOJ - Repository API DbRequest.java 0% ❌
BulkParams.java 0% -84.62% ❌

@nvamelichev
nvamelichev force-pushed the pluggable-YdbValidator branch from 299adc1 to 9335861 Compare November 5, 2026 22:17
@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown
Overall Project 55.1% -0.96% 🍏
Files changed 60.54% 🍏

Module Coverage
YOJ - In-Memory Repository 85.88% 🍏
YOJ - YDB Repository (SDK v2.x) 75.55% -1.14% 🍏
YOJ - Repository API 23.65% -2.07% ❌
Files
Module File Coverage
YOJ - In-Memory Repository InMemoryRepositoryTransaction.java 96.73% 🍏
InMemoryTable.java 88.81% 🍏
YOJ - YDB Repository (SDK v2.x) YdbSpliterator.java 90.48% 🍏
YdbRepositoryTransaction.java 79.65% -3.87% 🍏
SessionClient.java 79.49% 🍏
YdbRepository.java 71.2% 🍏
FindStatement.java 71.03% 🍏
YdbValidatorClassic.java 64.05% -35.95% 🍏
YdbSessionManager.java 50.47% -16.82% 🍏
YdbOperations.java 42.64% -36.43% ❌
YOJ - Repository API DbRequest.java 0% ❌
BulkParams.java 0% -84.62% ❌

…ory.Settings`

This opens the door for error handling customization that can work without changing the core error handling logic in `repository-ydb-v2`.
@nvamelichev
nvamelichev force-pushed the pluggable-YdbValidator branch from 9335861 to d13cf4e Compare November 5, 2026 22:21
@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown
Overall Project 55.1% -0.96% 🍏
Files changed 60.54% 🍏

Module Coverage
YOJ - In-Memory Repository 85.88% 🍏
YOJ - YDB Repository (SDK v2.x) 75.55% -1.14% 🍏
YOJ - Repository API 23.65% -2.07% ❌
Files
Module File Coverage
YOJ - In-Memory Repository InMemoryRepositoryTransaction.java 96.73% 🍏
InMemoryTable.java 88.81% 🍏
YOJ - YDB Repository (SDK v2.x) YdbSpliterator.java 90.48% 🍏
YdbRepositoryTransaction.java 79.65% -3.87% 🍏
SessionClient.java 79.49% 🍏
YdbRepository.java 71.2% 🍏
FindStatement.java 71.03% 🍏
YdbValidatorClassic.java 64.05% -35.95% 🍏
YdbSessionManager.java 50.47% -16.82% 🍏
YdbOperations.java 42.64% -36.43% ❌
YOJ - Repository API DbRequest.java 0% ❌
BulkParams.java 0% -84.62% ❌

} else if (ex instanceof TimeoutException) {
return convertToUnavailable(ex);
} else if (ex instanceof ExecutionException) {
if (ex.getCause() instanceof RepositoryException re) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

just interestign - what problem solves this if ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

scan query used to throw a mostly useless-for-error-handling RepositoryException("Caught ExecutionException", cause=ResultTruncatedException("...")); now we throw ResultTruncatedException directly. See the updated RepositoryTest for the difference.

* Validates that {@code status} is successful, and throws an appropriate subtype of {@link RepositoryException}
* if {@code status} is an error.
*
* @param request Information about YDB request being made. You may inspect its {@link DbRequest#getType()} type},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reading this 14-line comment, I don’t think it adds much beyond what the method signature already tells us. I’d keep the first two lines at most and remove the rest.

In general, I’d prefer fewer comments. I think comments should be short and explain decisions that aren’t obvious from the code. For everything else, I’d aim to make the code clear enough to speak for itself.

I get that this is a common Java style, but it feels very verbose, and I’m worried we’ll get lost in all these comments.

* <li>{@link #GET_SESSION GET_SESSION - getSession()}</li>
* </ul>
*/
@Value

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

issue: record?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I've started with a record but that didn't give me enough flexibility to have a private all-args constructor to prevent people from constructing their own e.g. commit operations with a non-empty args list

*/
public static final DbRequest GET_SESSION = new DbRequest(Type.GET_SESSION);

private DbRequest(@NonNull Type type) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

issue: I think it would be better to inline this: GET_SESSION = new DbRequest(Type.GET_SESSION, List.of());

This constructor only saves a few characters, but the call doesn’t make it clear what args contains. You have to check the constructor implementation and then come back. Inlining it would save that extra step.

}

public static DbRequest dataQuery(@Nullable String log) {
return new DbRequest(Type.DATA_QUERY, singletonList(log));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: singletonList won’t give us a performance benefit here, and we use List.of() everywhere else. I find the inconsistency a bit confusing, so I’d use List.of() throughout.

@nvamelichev nvamelichev Nov 6, 2026 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

log might genuinely be null (because Statement.toDebugParams(...) currently may return null and actually does this in RepositoryTest), and List.of() doesn't permit null elements.

That's why we use singletonList() here and for scan query. And that's a minor implementation detail, which we'll likely fix when we overhaul statement logging (for which I have a few long-waiting PRs ;-) )

SCAN_QUERY {
@Override
public String formatPrefix() {
return "scan().";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe we could use a new, consistent approach here instead of repeating the old logic? Let’s have everything go through .scanQuery(), .dataQuery(), .readTable(), and .rollback().

It seems like this would simplify the code without losing any information in the logs. What do you think?


@NonNull
@Override
public String toString() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Something feels a bit off here. I tried using a sealed interface, and I think the result looks cleaner: https://pastebin.com/9CFfxzRy

@InternalApi
@RequiredArgsConstructor(access = PRIVATE)
@ExperimentalApi(issue = "https://github.com/ydb-platform/yoj-project/issues/165")
public class DbRequest {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The name feels too generic. Maybe DbRequestLog or something similar would make it clearer that this is only used for logging?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

experimental feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve handling of UNDETERMINED results

2 participants