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(subscription): support cusor order #18801

Merged
merged 12 commits into from
Oct 25, 2024
Merged

feat(subscription): support cusor order #18801

merged 12 commits into from
Oct 25, 2024

Conversation

xxhZs
Copy link
Contributor

@xxhZs xxhZs commented Oct 8, 2024

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

What's changed and what's your intention?

#18208

In this pr, we'll make sure that the results returned by cursor are sorted by pk, making sure that we return the results in only one order, this is in order to later use pk+rw_timestamp+op to implement the cursor Exactly Once

And support explain fetch n from subscription cursor will return the batch plan of subscription cursor

Checklist

  • I have written necessary rustdoc comments
  • I have added necessary unit tests and integration tests
  • I have added test labels as necessary. See details.
  • 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.

@xxhZs xxhZs changed the title feat(subscription): support cusor order result feat(subscription): support cusor order Oct 8, 2024
fmt

rename
Copy link
Collaborator

@hzxa21 hzxa21 left a comment

Choose a reason for hiding this comment

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

Discussed offline: we can support explain fetch ... <cursor> in this PR so that we can understand more about the batch query plan.

@@ -351,6 +351,7 @@ impl SubscriptionCursor {
expected_timestamp,
init_query_timer,
};
println!("fields: {:?},???,{:?}", fields, self.fields);
Copy link
Collaborator

Choose a reason for hiding this comment

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

remove

fix

remove
@@ -89,7 +89,7 @@ impl Distill for BatchLogSeqScan {
vec.push(("distribution", dist));
}

childless_record("BatchScan", vec)
childless_record("BatchLogSeqScan", vec)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please include the epoch range and version id in the result as well.

@hzxa21
Copy link
Collaborator

hzxa21 commented Oct 21, 2024

It seems that the ordering doesn't work. Example:

dev=> create table a(v int, pk int primary key);
CREATE_TABLE
dev=> create subscription b from a with (retention = '1d');
CREATE_SUBSCRIPTION
dev=> declare cursor subscription cursor for b;
DECLARE_CURSOR
dev=> insert into a values(120, 25),(119, 23);
INSERT 0 2
dev=> flush;
FLUSH
dev=> fetch 2 from cursor;
  v  | pk |   op   | rw_timestamp  
-----+----+--------+---------------
 120 | 25 | Insert | 1729493767419
 119 | 23 | Insert | 1729493767419
(2 rows)

dev=> explain fetch 2 from cursor;
                      QUERY PLAN                      
------------------------------------------------------
 BatchExchange { order: [a.pk ASC], dist: Single }
 └─BatchLogSeqScan { table: a, columns: [v, pk, op] }
(2 rows)

.flatten_unordered(1024),
};
// All need merge
_ => merge_sort(iterators.into_iter().map(Box::pin).collect()),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Like the normal batch iterator, can we have a ordered option to determine whether merge_sort is needed?

See

let ordered = seq_scan_node.ordered;
and

fix comm

snapshot not merge
Copy link

gitguardian bot commented Oct 22, 2024

⚠️ GitGuardian has uncovered 4 secrets following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secrets in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
9425213 Triggered Generic Password b96f3e2 risedev.yml View secret
9425213 Triggered Generic Password b96f3e2 e2e_test/source_inline/tvf/postgres_query.slt View secret
9425213 Triggered Generic Password b96f3e2 e2e_test/source_inline/tvf/postgres_query.slt View secret
9425213 Triggered Generic Password b15cee9 ci/scripts/e2e-source-test.sh View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secrets safely. Learn here the best practices.
  3. Revoke and rotate these secrets.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

@graphite-app graphite-app bot requested a review from a team October 22, 2024 08:09
Copy link
Collaborator

@hzxa21 hzxa21 left a comment

Choose a reason for hiding this comment

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

Rest LGTM!

@@ -126,6 +129,8 @@ impl TryToBatchPb for BatchLogSeqScan {
},
)),
}),
// It's currently true.
ordered: true,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's make this consistent with BatchSeqScan:

ordered: !self.order().is_any()

@xxhZs xxhZs enabled auto-merge October 25, 2024 06:53
@xxhZs xxhZs added this pull request to the merge queue Oct 25, 2024
Merged via the queue into main with commit fcb6c35 Oct 25, 2024
31 of 32 checks passed
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.

2 participants