Repository navigation
Clean up code for transaction management and auth - #974
Merged
Merged
Conversation
Signed-off-by: Vikrant Puppala <[email protected]>
Signed-off-by: Vikrant Puppala <[email protected]>
Signed-off-by: Vikrant Puppala <[email protected]>
Signed-off-by: Vikrant Puppala <[email protected]>
Signed-off-by: Vikrant Puppala <[email protected]>
Signed-off-by: Vikrant Puppala <[email protected]>
Signed-off-by: Vikrant Puppala <[email protected]>
vikrantpuppala
requested review from
dennyglee,
rameshchandra and
tdas
as code owners
April 16, 2025 13:28
# Conflicts: # server/src/main/java/io/unitycatalog/server/service/CredentialService.java
Signed-off-by: Vikrant Puppala <[email protected]>
tdas
reviewed
Apr 29, 2025
| } | ||
|
|
||
| // If we're proceeding with force=true, delete all schemas with pagination | ||
| if (force) { |
Contributor
There was a problem hiding this comment.
why this change in logic?
and is this logic change covered in unit test?
Collaborator
Author
There was a problem hiding this comment.
this is only a slight change in how the if conditions are written, the logic is still the same. I don't think we have tests for force specifically.
tdas
reviewed
Apr 29, 2025
| try { | ||
| List<PropertyDAO> propertyDAOList = | ||
| PropertyRepository.findProperties(session, UUID.fromString(uuid), entityType); | ||
| if (propertyDAOList.isEmpty()) { |
Contributor
There was a problem hiding this comment.
how is this logic change tested?
Collaborator
Author
There was a problem hiding this comment.
I updated a test case to test this
JacquesT2
pushed a commit
to JacquesT2/unitycatalog
that referenced
this pull request
May 12, 2025
**PR Checklist** - [ ] A description of the changes is added to the description of this PR. - [ ] If there is a related issue, make sure it is linked to this PR. - [ ] If you've fixed a bug or added code that should be tested, add tests! - [ ] If you've added or modified a feature, documentation in `docs` is updated **Description of changes** <!-- Please state what you've changed and how it might affect the users. --> Clean up code for transaction management and auth --------- Signed-off-by: Vikrant Puppala <[email protected]> Signed-off-by: JacquesT2 <[email protected]>
shba24
added a commit
to shba24/unitycatalog
that referenced
this pull request
Oct 20, 2026
…error Since unitycatalog#974 moved createUser onto TransactionManager, a database error arrives as BaseException(INTERNAL), and the SCIM create catch-all mapped it to BadRequestException, so the error body said 400 and the 5xx was not logged. Map server-side codes to ServerErrorException with the original exception as the cause. Signed-off-by: Shubham Bansal <[email protected]> Co-authored-by: Isaac <[email protected]>
3 of 4 tasks
shba24
added a commit
to shba24/unitycatalog
that referenced
this pull request
Oct 22, 2026
…error Since unitycatalog#974 moved createUser onto TransactionManager, a database error arrives as BaseException(INTERNAL), and the SCIM create catch-all mapped it to BadRequestException, so the error body said 400 and the 5xx was not logged. Map server-side codes to ServerErrorException with the original exception as the cause. Signed-off-by: Shubham Bansal <[email protected]> Co-authored-by: Isaac <[email protected]>
shba24
added a commit
to shba24/unitycatalog
that referenced
this pull request
Oct 25, 2026
…error Since unitycatalog#974 moved createUser onto TransactionManager, a database error arrives as BaseException(INTERNAL), and the SCIM create catch-all mapped it to BadRequestException, so the error body said 400 and the 5xx was not logged. Map server-side codes to ServerErrorException with the original exception as the cause. Signed-off-by: Shubham Bansal <[email protected]> Co-authored-by: Isaac <[email protected]>
yili-db
pushed a commit
that referenced
this pull request
Oct 25, 2026
**PR Checklist**
- [x] A description of the changes is added to the description of this
PR.
- [ ] If there is a related issue, make sure it is linked to this PR.
- [x] If you've fixed a bug or added code that should be tested, add
tests!
- [x] If you've added or modified a feature, documentation in `docs` is
updated
**Description of changes**
A failed request left no trace in the server log, and the log lines one
request wrote could not be told apart from another's. With this change:
- Each log line written while serving a request has `request_id=<id>`,
the ID Armeria generates for that request, and every line names the host
(with the shipped log4j2 configs).
- Each 5xx is logged once at `ERROR` with its cause, where the error
response is built (UC, Iceberg, Delta, SCIM).
- Database errors keep their cause. A failed rollback or session close
is attached to the error instead of replacing it, and a replay signal
whose rollback fails returns 500. A custom isolation level is no longer
restored by hand: Hikari resets it when the connection returns to the
pool.
- A failed policy-refresh read is a `WARN`, because revokes from other
instances stop arriving until a read succeeds.
- Bootstrap creates the admin only when the lookup returns not-found.
Any other error fails startup.
**Compatibility:** the API is unchanged; no request or response header
is added. The default log line format gains the host name and
`request_id=`, so log parsers that match the old pattern need updating.
The Helm chart copies the log4j2 config template instead of running
`envsubst` on it, so a `${VAR}` in it is now a Log4j lookup. A 4xx whose
rollback also fails now returns that 4xx; before, it returned 500. A
transaction with a custom isolation level no longer checks out a second
connection after it commits, so a committed write can no longer come
back as a 500 when that checkout fails. Startup now fails if the admin
lookup fails with anything other than not-found, instead of treating it
as "no admin yet". A SCIM create-user that fails in the database now
reports `"status":"500"` in the SCIM error body instead of `"400"`; the
HTTP status stays 500. Log levels that alerts may match on change: the
token-exchange lookup failure moves from `ERROR` with a stack trace to
`WARN` without one, and the Casbin policy-refresh read failures move
from `DEBUG` to `WARN`.
<details><summary>📐 Design notes & details</summary>
- **Request ID:** the Armeria request context's own ID.
`RequestContextDataProvider`, a Log4j `ContextDataProvider`, exports
fields of the current Armeria request through Armeria's
`RequestContextExporter`, the same exporter Armeria's Logback
integration uses. Today it exports only `request_id`; another field is
one more `builtIn(...)` entry. The Armeria context follows the request
onto the blocking executor, where a per-thread MDC would not.
- **No header:** neither the Iceberg REST spec nor `api/all.yaml` /
`api/delta.yaml` defines a request-ID header, so this PR doesn't read
one from callers or return one. That would be new API surface, and it
can come later through the spec if wanted.
- **One place to log:** `BaseExceptionHandler.handleException` (and the
Iceberg handler's override of it, from #1984), using the status the
dialect actually answers with (Delta has its own), so each 5xx is logged
once, with only its cause: the request ID on the line identifies the
request. Token exchange still names the failed lookup (email or client
ID), now as a `WARN` without the stack trace, so the cause isn't logged
twice. A rollback or session-close failure behind a 4xx or a replay
signal, which the handler doesn't log, is a `WARN` from
`TransactionManager`.
- **SCIM:** it answers every error with HTTP 500 (unchanged here) and
logs by the SCIM error's own status, so a duplicate user isn't an
`ERROR`. `createScimUser` labelled database errors 400 since #974
wrapped them as `BaseException(INTERNAL)`; they now map to
`ServerErrorException` with the cause, so they are logged.
- **Armeria flags:** when a `com.linecorp.armeria.*` property is set,
Armeria logs during startup before its context storage exists. The
provider returns no fields for those lines instead of throwing, and
builds the exporter only once a request is served, as Armeria's own
appender does.
- **Not in this PR:** JSON or stdout logging, a setting for the
log-config path, a build check for catch blocks that drop the exception,
the SCIM 500 status, and `DeltaPropertyMapper` dropping its cause.
- **Tests:** an end-to-end test in `AuthServiceTest` makes the database
reject a SCIM user insert and checks the 500 status in the body;
`TransactionManagerTest` fails each point in turn (isolation set,
operation, commit, rollback, session close) and checks the thrown error,
its cause and the suppressed failures; its existing real-database test
checks that the level is back to the original after a transaction; two
bootstrap tests are in `UserRepositoryTest`;
`UnityCatalogServerTest.logLinesCarryTheRequestId` checks that Log4j
finds the provider and that it supplies the request ID inside a request
and nothing outside one. There are no log-output tests. `build/sbt test`
passed at b9cab14, except for one run of
`SdkModelCRUDTest.testModelCRUD`, a known same-millisecond timing flake
in model updates that this PR doesn't touch; it passes on rerun. The
later commits, and the rebase onto main at 4626de6, were checked with
the test classes they touch.
</details>
This pull request and its description were written by Isaac.
---------
Signed-off-by: Shubham Bansal <[email protected]>
Co-authored-by: Isaac <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Checklist
docsis updatedDescription of changes
Clean up code for transaction management and auth