Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support show and cancel jobs syntax #11854

Merged
merged 4 commits into from
Aug 24, 2023
Merged

Conversation

yezizp2012
Copy link
Member

@yezizp2012 yezizp2012 commented Aug 23, 2023

I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.

What's changed and what's your intention?

Resolve #8032 , support syntax to show and cancel creating streaming jobs:

dev=> show jobs;
  Id  |                     Statement                     | Progress
------+---------------------------------------------------+----------
 1010 | CREATE MATERIALIZED VIEW mv3 AS SELECT * FROM mv1 | 2.21%
 1012 | CREATE MATERIALIZED VIEW mv2 AS SELECT * FROM mv1 | 0.86%
(2 rows)

dev=> cancel jobs 1010, 1012;
  Id
------
 1012
 1010
(2 rows)

Checklist

  • I have written necessary rustdoc comments
  • I have added necessary unit tests and integration tests
  • I have added fuzzing tests or opened an issue to track them. (Optional, recommended for new SQL features Sqlsmith: Sql feature generation #7934).
  • My PR contains breaking changes. (If it deprecates some features, please create a tracking issue to remove them in the future).
  • All checks passed in ./risedev check (or alias, ./risedev c)
  • My PR changes performance-critical code. (Please run macro/micro-benchmarks and show the results.)
  • My PR contains critical fixes that are necessary to be merged into the latest release. (Please check out the details)

Documentation

  • My PR needs documentation updates. (Please use the Release note section below to summarize the impact on users)

Release note

If this PR includes changes that directly affect users or other significant modifications relevant to the community, kindly draft a release note to provide a concise summary of these changes. Please prioritize highlighting the impact these changes will have on users.

support syntax to show and cancel creating streaming jobs.

@yezizp2012 yezizp2012 added the user-facing-changes Contains changes that are visible to users label Aug 23, 2023
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

license-eye has totally checked 3979 files.

Valid Invalid Ignored Fixed
1753 1 2225 0
Click to see the invalid file list
  • src/frontend/src/handler/cancel_job.rs

src/frontend/src/handler/cancel_job.rs Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Aug 23, 2023

Codecov Report

Merging #11854 (817a845) into main (261cb80) will decrease coverage by 0.04%.
Report is 6 commits behind head on main.
The diff coverage is 2.75%.

@@            Coverage Diff             @@
##             main   #11854      +/-   ##
==========================================
- Coverage   70.22%   70.18%   -0.04%     
==========================================
  Files        1373     1374       +1     
  Lines      228708   228818     +110     
==========================================
- Hits       160608   160599       -9     
- Misses      68100    68219     +119     
Flag Coverage Δ
rust 70.18% <2.75%> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
src/frontend/src/handler/cancel_job.rs 0.00% <0.00%> (ø)
src/frontend/src/meta_client.rs 0.00% <0.00%> (ø)
src/frontend/src/scheduler/streaming_manager.rs 66.66% <0.00%> (-2.09%) ⬇️
src/frontend/src/test_utils.rs 75.51% <0.00%> (ø)
src/meta/src/manager/catalog/mod.rs 28.83% <ø> (ø)
src/meta/src/rpc/service/stream_service.rs 0.00% <0.00%> (ø)
src/meta/src/stream/stream_manager.rs 74.08% <0.00%> (-1.68%) ⬇️
src/rpc_client/src/meta_client.rs 4.09% <0.00%> (ø)
src/sqlparser/src/ast/mod.rs 85.13% <0.00%> (-0.33%) ⬇️
src/sqlparser/src/keywords.rs 100.00% <ø> (ø)
... and 4 more

... and 4 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Member

@BugenZhao BugenZhao left a comment

Choose a reason for hiding this comment

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

LGTM!!

src/meta/src/stream/stream_manager.rs Outdated Show resolved Hide resolved
src/meta/src/stream/stream_manager.rs Show resolved Hide resolved
@neverchanje
Copy link
Contributor

neverchanje commented Aug 24, 2023

I am wondering if you have got the wrong idea what a job is in cockroachdb. A job specifically refers to a "system maintanence task" https://www.cockroachlabs.com/docs/stable/ui-jobs-page. The correct syntax that we can follow is https://www.cockroachlabs.com/docs/stable/cancel-query CANCEL QUERY. We'll need SHOW STATEMENTS; as well instead of SHOW JOBS.

My concern is that users will have to understand one more concept if you use JOB to indicate a query or statement.

I also found that this requirement is common and most systems prefer to implement a non-standard syntax for it.

Database Cancel Syntax Show Queries Syntax
CockroachDB CANCEL QUERY <query_id>; SHOW STATEMENTS;
Snowflake SYSTEM$CANCEL_QUERY(query_id); SHOW STATEMENTS;
PostgreSQL pg_cancel_backend(pid); SELECT pid FROM pg_stat_activity;
Oracle ALTER SYSTEM CANCEL SQL 'sid, serial#'; SELECT sid, serial# FROM v$session WHERE sql_id = 'YOUR_SQL_ID';
SQL Server KILL session_id; SELECT session_id FROM sys.dm_exec_requests WHERE sql_text = 'YOUR_QUERY_TEXT';

@yezizp2012
Copy link
Member Author

yezizp2012 commented Aug 24, 2023

@neverchanje suggested that not to introduce a new job concept but to cancel creating streaming jobs with existed command like DROP MATERIALIZED VIEW xx. It makes sense to me, but in the current implementation we don't have streaming jobs exposed on the frontend and persisted in the meta during creation, which would make the implementation a bit cumbersome, and having the DROP MATERIALIZED VIEW semantics ambiguous, especially since we also support the IF NOT EXISTS keywords.
But in this future, when we support #8051 and expose it in frontend, using DROP syntax will be more logical and natural. For now let's support the job syntax firstly to let user can cancel it first.

@BugenZhao
Copy link
Member

What about simply calling it DDL or DDL JOB?

@yezizp2012
Copy link
Member Author

yezizp2012 commented Aug 24, 2023

I am wondering if you have got the wrong idea what a job is in cockroachdb. A job specifically refers to a "system maintanence task" cockroachlabs.com/docs/stable/ui-jobs-page. The correct syntax that we can follow is cockroachlabs.com/docs/stable/cancel-query CANCEL QUERY. We'll need SHOW STATEMENTS; as well instead of SHOW JOBS.

My concern is that users will have to understand one more concept if you use JOB to indicate a query or statement.

Well I think it's much more like ADMIN CANCEL DDL JOBS xxx in docs.pingcap.com/tidb/stable/sql-statement-admin-cancel-ddl. Adding a DDL keyword will make more sense for us.

@neverchanje
Copy link
Contributor

neverchanje commented Aug 24, 2023

I personally suggest:

- Use CANCEL <job_id> for cancelling both ddl and batch queries.
- Use SHOW STATEMENTS or a system catalog such as pg_stat_activity and rw_running_statements to present all running queries.

Well, the cancel jobs looks acceptable to me now. in the future we can implement cancel query for cancelling batch queries.

@yezizp2012 yezizp2012 enabled auto-merge August 24, 2023 08:22
@yezizp2012 yezizp2012 added this pull request to the merge queue Aug 24, 2023
Merged via the queue into main with commit 3b7d67b Aug 24, 2023
@yezizp2012 yezizp2012 deleted the zp/show-cancel-jobs branch August 24, 2023 09:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/feature user-facing-changes Contains changes that are visible to users
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ddl: cancel with SQL command
3 participants