[ 
https://issues.apache.org/jira/browse/MAPREDUCE-7547?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18123083#comment-18123083
 ] 

ASF GitHub Bot commented on MAPREDUCE-7547:
-------------------------------------------

joseluisll opened a new pull request, #8790:
URL: https://github.com/apache/hadoop/pull/8790

   ### Description of PR
   
   JIRA: https://issues.apache.org/jira/browse/MAPREDUCE-7547
   
   MAPREDUCE-7527 (#8285) fixed the JobHistoryServer attempts page by binding 
`App` as a singleton in `HsWebApp`. `App` carries per-request state: 
`AppController.requireJob()`/`requireTask()` (inherited by `HsController`) call 
`app.setJob()`/`app.setTask()`, and the view reads them back. As a singleton, 
that state is shared by every concurrent JHS request, so one request can render 
another request's job.
   
   This binds `App` request-scoped instead, matching what was agreed for the AM 
web UI in MAPREDUCE-7541 (#8652).
   
   ### How was this patch tested?
   
   Added two tests to `TestHSWebApp`:
   - `testAppBindingIsRequestScoped` checks the `App` binding's scope through 
the Guice SPI. It fails with the previous `Singleton` binding and with no 
binding at all.
   - `testAttemptsPageRender` starts a real `HsWebApp` on mock jobs and 
requests `/jobhistory/attempts/<job>/m/<state>`, asserting HTTP 200 and that a 
known attempt id is listed. It fails without the `App` binding, which guards 
the MAPREDUCE-7527 fix.
   
   `mvn test -Dtest=TestHSWebApp` in `hadoop-mapreduce-client-hs`: 19 tests, 0 
failures.
   
   ### For code changes:
   
   - [x] Does the title of this PR start with the corresponding JIRA issue id 
(e.g. 'HADOOP-17799. Your PR title ...')?
   - [ ] Object storage: Have the integration tests been executed and the 
endpoint
         declared according to the connector-specific documentation? *Note: 
Automated CI
         testing doesn't cover all cases so manual testing with cloud storage 
is still
         required.*
   - [ ] If adding new dependencies to the code, are these dependencies 
licensed in a way that is compatible for inclusion under [ASF 
2.0](http://www.apache.org/legal/resolved.html#category-a)?
   - [ ] If applicable, have you updated the `LICENSE`, `LICENSE-binary`, 
`NOTICE-binary` files?
   
   ### AI Tooling
   
   If an AI tool was used:
   
   - [x] The PR includes the phrase "Contains content generated by <tool>"
         where <tool> is the name of the AI tool used.
   - [ ] My use of AI contributions follows the ASF legal policy
         https://www.apache.org/legal/generative-tooling.html
   
   Contains content generated by Claude Code.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   




> HsWebApp should bind App request-scoped instead of singleton
> ------------------------------------------------------------
>
>                 Key: MAPREDUCE-7547
>                 URL: https://issues.apache.org/jira/browse/MAPREDUCE-7547
>             Project: Hadoop Map/Reduce
>          Issue Type: Bug
>          Components: jobhistoryserver, webapps
>            Reporter: Jose Luis López
>            Assignee: Jose Luis López
>            Priority: Major
>
> MAPREDUCE-7527 fixed the JobHistoryServer attempts page by binding {{App}} as 
> a singleton in {{HsWebApp.setup()}}:
> {code:java}
> bind(App.class).in(Singleton.class);
> {code}
> {{App}} holds per-request mutable state: {{AppController.requireJob()}} / 
> {{requireTask()}} (inherited by {{HsController}}) call {{app.setJob(...)}} / 
> {{app.setTask(...)}}, and the rendered view reads them back via 
> {{app.getJob()}} / {{app.getTask()}}. With a singleton, every request to the 
> JHS shares one {{App}} instance, so concurrent requests can overwrite each 
> other's job/task and a page can render data for a different job than the one 
> requested.
> The equivalent fix for the AM web UI, MAPREDUCE-7541 
> (https://github.com/apache/hadoop/pull/8652), was reviewed with this exact 
> concern and uses request scope instead:
> {code:java}
> bind(App.class).in(RequestScoped.class);
> {code}
> The JHS is long-lived and serves all users, so it should use the same 
> request-scoped binding.
> *Proposed change*
> * In {{HsWebApp.setup()}}, change {{Singleton.class}} to 
> {{com.google.inject.servlet.RequestScoped.class}}.
> * Add a regression test that starts the JHS web app and requests 
> {{/jobhistory/attempts/<job_id>/m/SUCCESSFUL}}, asserting attempt rows are 
> rendered (guards MAPREDUCE-7527), and ideally that two different jobs' pages 
> each render their own job.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to