lasdf1234 opened a new issue, #14999:
URL: https://github.com/apache/gravitino/issues/14999

   ### Version
   
   main branch
   
   ### Describe what's wrong
   
   When authorization/ownership is enabled, TMS cron and commit submit paths 
call `JobManager.runJob` on scheduler threads that have no authenticated 
subject. `PrincipalUtils.getCurrentUserName()` therefore resolves to 
`anonymous`, and `JobManager.registerAndSubmit` tries to set the job owner to 
that user.
   
   If the metalake has no user named `anonymous`, submit fails, no maintenance 
Spark job is created, and soft-slot claims are released.
   
   ### Error message and/or stacktrace
   
   ```
   WARN  OwnerManager - Metadata object job-<id> or owner anonymous is not found
   org.apache.gravitino.exceptions.NoSuchEntityException: No such user entity: 
anonymous
        at 
org.apache.gravitino.storage.relational.service.UserMetaService.getUserIdByMetalakeIdAndName(...)
        at org.apache.gravitino.authorization.OwnerManager.setOwner(...)
        at org.apache.gravitino.job.JobManager.registerAndSubmit(...)
        at org.apache.gravitino.job.JobManager.runJob(...)
        at 
org.apache.gravitino.maintenance.MaintenanceJobManager.submitAndBind(...)
   ```
   
   ### How to reproduce
   
   1. Enable authorization/ownership on the server.
   2. Create a metalake whose owner is a real user (for example `admin`), and 
do **not** create a user named `anonymous`.
   3. Enable TMS and schedule a maintenance policy with a frequent 
`timeTrigger`.
   4. Wait for PolicyExpand to schedule a cron-job row, then observe cron 
submit fail in `MaintenanceJobManager.submitAndBind` with `No such user entity: 
anonymous`.
   5. Confirm that a manual `POST /jobs/runs` as an authenticated metalake user 
still succeeds.
   
   ### Additional context
   
   - Kind: product bug in TMS background submit identity.
   - Root cause: scheduler threads are unauthenticated, while job registration 
requires a USER owner entity.
   - Proposed fix: when ownership is enabled, run TMS `runJob` as the metalake 
owner user (USER). When ownership is disabled, `JobManager` already skips 
`setOwner` and no principal switch is needed.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to