Skip to content

refactor(services): use the shared request-logging filter and SQL-state constant - #7796

Merged
aglinxinyuan merged 4 commits into
apache:mainfrom
aglinxinyuan:refactor/shared-filter-and-sqlstate
Oct 12, 2026
Merged

aglinxinyuan merged 4 commits into
apache:mainfrom
aglinxinyuan:refactor/shared-filter-and-sqlstate

Conversation

@aglinxinyuan

@aglinxinyuan aglinxinyuan commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

Two places where a shared helper already existed but a local copy or literal was used instead. 9 insertions, 27 deletions.

1. WorkflowCompilingService now calls the shared RequestLoggingFilter. It was the only Dropwizard-4 service still inlining its own anonymous request-logging filter; the other five (access-control, computing-unit-managing, config, file, notebook-migration) all call RequestLoggingFilter.register(environment.getApplicationContext) at exactly this point.

The two implementations were compared line by line before swapping, not assumed equivalent. Normalising fully-qualified prefixes and the logger's local name, every observable matches: logger name "org.eclipse.jetty.server.RequestLog", the isInfoEnabled guard, the same access-log format string, url pattern "/*", and EnumSet.allOf(classOf[DispatcherType]). The inline copy also sat immediately after RoleAnnotationEnforcer.enforce, which is exactly where the siblings place the register call — so this is a body-only replacement.

2. Four sites now use SqlStates.UNIQUE_VIOLATION instead of the literal "23505".

Site Was
PveResource.scala:110, :148 e.sqlState() == "23505"
NotebookMigrationResource.scala:404 e.sqlState == "23505"
JupyterProvisioner.scala:168 e.sqlState == "23505"

Both modules can already see common/dao: NotebookMigrationService has a direct DAO dependency, and amber reaches it transitively (Auth → DAO, and WorkflowCompiler → WorkflowOperator → WorkflowCore → DAO). No build change was needed. The constant was already in use by ExternalAuthProvisioner, LocalAuthProvisioner and ResourceNaming.

The remaining 23505 occurrences are CSV test fixtures, a yarn.lock checksum, SqlStates.scala itself, and three comments that explain what the code means — those are left alone.

Updated after merging main. The DatasetResource.scala site originally in this PR is gone: main (#7760) moved that check into ResourceNaming.failOnDuplicateName, which already uses SqlStates.UNIQUE_VIOLATION, so DatasetResource.scala is now identical to main. main also added a new literal in JupyterProvisioner.register (#8032), which this PR now converts as well.

amber's two inline copies are deliberately untouched

Worth recording so they are not "fixed" later: amber's remaining inline filters cannot use the shared one. They are javax.servlet, because amber pins Jetty 9.4.20, while RequestLoggingFilter is jakarta.servlet. Their existing TODO — replace once Dropwizard is upgraded — is accurate, and this PR does not touch them.

Verification

Re-run on the branch after merging main:

  • WorkflowCompilingService/test: 5 suites, 55 tests, 0 failures. This matters because WorkflowCompilingServiceRunSpec has cases asserting the filter's registration, its dispatch set, and that it forwards the request while logging one access line. They read the filter back out of the captured FilterHolder rather than by class, so they survived the swap unchanged — and they are what confirms the shared filter behaves identically in place.
  • NotebookMigrationService/test: 6 suites, 123 tests, 0 failures. NotebookMigrationResourceSpec drives a real unique-constraint violation against embedded Postgres, and its "keep the winning row when two requests provision at once" case exercises the JupyterProvisioner race path.
  • PveResourceSpec fails the same 6 tests both with and without this change (45 succeeded / 6 failed / 1 canceled either way, verified by swapping in main's PveResource.scala and re-running; identical failing set). All 6 are PveManager venv/pip cases that are pre-existing on this machine; none touch the 23505 → 409 paths.
  • scalafmtCheckAll and scalafixAll --check pass for WorkflowCompilingService, NotebookMigrationService, FileService and WorkflowExecutionService; no imports were left orphaned (FilterHolder removed, RequestLoggingFilter added).

Any related issues, documentation, discussions?

Closes #7792

How was this PR tested?

sbt "WorkflowCompilingService/test" "NotebookMigrationService/test" "WorkflowExecutionService/testOnly org.apache.texera.web.resource.pythonvirtualenvironment.PveResourceSpec"
[info] Tests: succeeded 55, failed 0, canceled 0, ignored 0, pending 0
[info] Tests: succeeded 123, failed 0, canceled 0, ignored 0, pending 0
[info] Tests: succeeded 45, failed 6, canceled 1, ignored 0, pending 0   (identical on main)

Was this PR authored or co-authored using generative AI tooling?

Generated-by: Claude Code (Opus 5)

Copilot AI lite review requested due to automatic review settings August 19, 2026 23:10

Copilot AI left a comment

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions github-actions Bot added engine refactor Refactor the code platform Non-amber Scala service paths labels Aug 19, 2026
@github-actions

github-actions Bot commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

Automated Reviewer Suggestions

Based on the git blame history of the changed files, we recommend the following reviewers:

  • Contributors with relevant context: @zyratlo, @SarahAsad23
    You can notify them by mentioning @zyratlo, @SarahAsad23 in a comment.

@codecov-commenter

codecov-commenter commented Aug 19, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.60%. Comparing base (f01f63d) to head (2d4fefd).

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #7796   +/-   ##
=========================================
  Coverage     92.60%   92.60%           
  Complexity     5044     5044           
=========================================
  Files          1252     1252           
  Lines         53574    53559   -15     
  Branches       6673     6668    -5     
=========================================
- Hits          49611    49600   -11     
+ Misses         2317     2316    -1     
+ Partials       1646     1643    -3     
Flag Coverage Δ *Carryforward flag
access-control-service 77.38% <ø> (ø) Carriedforward from f01f63d
agent-service 99.16% <ø> (ø) Carriedforward from f01f63d
amber 88.11% <ø> (+<0.01%) ⬆️ Carriedforward from f01f63d
computing-unit-managing-service 60.48% <ø> (ø)
config-service 87.37% <ø> (ø)
file-service 81.53% <ø> (ø) Carriedforward from f01f63d
frontend 96.58% <ø> (ø) Carriedforward from f01f63d
notebook-migration-service 84.13% <ø> (+0.40%) ⬆️ Carriedforward from f01f63d
pyamber 98.52% <ø> (ø) Carriedforward from f01f63d
workflow-compiling-service 72.25% <ø> (-1.84%) ⬇️ Carriedforward from f01f63d

*This pull request uses carry forward flags. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

github-actions Bot commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Benchmark changes need a look

🟢 2 better · 🔴 5 worse · ⚪ 8 noise (<±5%) · 0 without baseline

Compared against main f01f63d benchmarked on this same runner, so the delta is largely free of cross-runner hardware noise. The "7d avg" column still reflects the gh-pages dashboard. Treat <±5% as noise unless repeated.

Dashboard · Run

config throughput MB/s latency max Δ latest / 7d
🔴 bs=10 sw=10 sl=64 710 0.433 14,204/17,425/17,425 us 🟢 -28.3% / 🔴 +18.8%
🔴 bs=100 sw=10 sl=64 1,585 0.968 61,709/83,015/83,015 us 🔴 +7.7% / 🟢 +42.7%
🔴 bs=1000 sw=10 sl=64 1,983 1.21 501,178/587,659/587,659 us 🔴 +6.5% / 🟢 +73.9%
Baseline details

Latest main f01f63d from same runner

config metric PR latest main 7d avg Δ latest Δ 7d
bs=10 sw=10 sl=64 throughput 710 tuples/sec 696 tuples/sec 866.99 tuples/sec +2.0% -18.1%
bs=10 sw=10 sl=64 MB/s 0.433 MB/s 0.425 MB/s 0.529 MB/s +1.9% -18.2%
bs=10 sw=10 sl=64 p50 14,204 us 12,342 us 11,989 us +15.1% +18.5%
bs=10 sw=10 sl=64 p95 17,425 us 24,318 us 14,672 us -28.3% +18.8%
bs=10 sw=10 sl=64 p99 17,425 us 24,318 us 17,906 us -28.3% -2.7%
bs=100 sw=10 sl=64 throughput 1,585 tuples/sec 1,642 tuples/sec 1,111 tuples/sec -3.5% +42.6%
bs=100 sw=10 sl=64 MB/s 0.968 MB/s 1.002 MB/s 0.678 MB/s -3.4% +42.7%
bs=100 sw=10 sl=64 p50 61,709 us 59,053 us 95,405 us +4.5% -35.3%
bs=100 sw=10 sl=64 p95 83,015 us 77,097 us 102,332 us +7.7% -18.9%
bs=100 sw=10 sl=64 p99 83,015 us 77,097 us 115,219 us +7.7% -28.0%
bs=1000 sw=10 sl=64 throughput 1,983 tuples/sec 1,952 tuples/sec 1,141 tuples/sec +1.6% +73.9%
bs=1000 sw=10 sl=64 MB/s 1.21 MB/s 1.191 MB/s 0.696 MB/s +1.6% +73.8%
bs=1000 sw=10 sl=64 p50 501,178 us 512,640 us 938,794 us -2.2% -46.6%
bs=1000 sw=10 sl=64 p95 587,659 us 552,044 us 984,521 us +6.5% -40.3%
bs=1000 sw=10 sl=64 p99 587,659 us 552,044 us 1,008,827 us +6.5% -41.7%
Raw CSV
config_idx,batch_size,schema_width,string_len,num_batches,total_ms,total_tuples,total_bytes,tuples_per_sec,mb_per_sec,lat_p50_us,lat_p95_us,lat_p99_us
0,10,10,64,20,281.75,200,128000,710,0.433,14203.99,17425.37,17425.37
1,100,10,64,20,1261.55,2000,1280000,1585,0.968,61708.58,83015.42,83015.42
2,1000,10,64,20,10085.45,20000,12800000,1983,1.210,501177.76,587659.42,587659.42

@aglinxinyuan
aglinxinyuan requested a review from mengw15 August 20, 2026 05:23
@aglinxinyuan
aglinxinyuan requested a review from kunwp1 October 10, 2026 08:51
…r-and-sqlstate

# Conflicts:
#	file-service/src/main/scala/org/apache/texera/service/resource/DatasetResource.scala
#	workflow-compiling-service/src/main/scala/org/apache/texera/service/WorkflowCompilingService.scala

Copilot AI left a comment

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.

🟢 Approval recommended

No unresolved issues were identified that would block approval.

0 open findings

🧠 Review effort: Lite

@aglinxinyuan
aglinxinyuan added this pull request to the merge queue Oct 12, 2026
Merged via the queue into apache:main with commit fd25ce8 Oct 12, 2026
33 checks passed
@aglinxinyuan
aglinxinyuan deleted the refactor/shared-filter-and-sqlstate branch October 12, 2026 04:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

engine platform Non-amber Scala service paths refactor Refactor the code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use the shared request-logging filter and SQL-state constant instead of local copies

4 participants