-
Notifications
You must be signed in to change notification settings - Fork 594
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
refactor(connector-node): jni reuse bidi stream handle #13131
Conversation
6e80b67
to
2bb1fee
Compare
|
GitGuardian id | Secret | Commit | Filename | |
---|---|---|---|---|
7648795 | Generic CLI Secret | 2bb1fee | integration_tests/iceberg-cdc/run_test.sh | View secret |
7648795 | Generic CLI Secret | 2bb1fee | integration_tests/iceberg-cdc/docker-compose.yml | View secret |
🛠 Guidelines to remediate hardcoded secrets
- Understand the implications of revoking this secret by investigating where it is used in your code.
- Replace and store your secrets safely. Learn here the best practices.
- Revoke and rotate these secrets.
- 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
- following these best practices for managing and storing secrets including API keys and other credentials
- install secret detection on pre-commit to catch secret before it leaves your machine and ease remediation.
🦉 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.
Our GitHub checks need improvements? Share your feedbacks!
Codecov Report
@@ Coverage Diff @@
## main #13131 +/- ##
==========================================
+ Coverage 68.23% 68.32% +0.08%
==========================================
Files 1501 1501
Lines 253235 253108 -127
==========================================
+ Hits 172794 172927 +133
+ Misses 80441 80181 -260
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 16 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
src/jni_core/src/jvm_runtime.rs
Outdated
if let Ok(jvm) = JVM.get() { | ||
let result: Result<(usize, usize), jni::errors::Error> = try { | ||
let mut env = jvm.attach_current_thread()?; | ||
|
||
let runtime_instance = env.call_static_method( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously, we used OnceLock here to avoid initializing a JVM when the memory controller collects jvm memory statistics.
#12965 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! I have changed to avoid initialize the jvm when collecting metrics.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rest LGTM. Thanks!
src/jni_core/src/jvm_runtime.rs
Outdated
pub fn for_initialized_jvm<O, F: FnOnce(&'static JavaVM) -> O>(&self, f: F) -> Option<O> { | ||
JVM_RESULT.get().and_then(|result| { | ||
if let Ok(jvm) = result { | ||
Some(f(jvm)) | ||
} else { | ||
None | ||
} | ||
}) | ||
} | ||
|
||
pub fn get_or_init(&self) -> Result<&JavaVM, &RwError> { | ||
self.0.get_or_init(Self::inner_new).as_ref() | ||
pub fn get(&self) -> anyhow::Result<&'static JavaVM> { | ||
match JVM_RESULT.get_or_init(|| { | ||
Self::inner_new().inspect_err(|e| error!("failed to init jvm: {:?}", e)) | ||
}) { | ||
Ok(jvm) => Ok(jvm), | ||
Err(e) => Err(anyhow!("jvm not initialized properly: {:?}", e)), | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should follow API
semantics of the OnceLock
since we use OnceLock
as the internal implementation. There are 2 methods get
and get_or_init
in OnceLock
, but in this PR, we use for_initialized_jvm
and get
corresponding instead which might cause confusion. What about following the same method naming of OnceLock
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sense.
I just changed the current get
back to get_or_init
. The original get
will be removed since it is only used by load_jvm_memory_stats
which is in the same mod as JvmWrapper
and it can use the JVM_RESULT
directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
generally LGTM
src/rpc_client/src/lib.rs
Outdated
|
||
let first_response = response_stream | ||
.next() | ||
.await | ||
.ok_or_else(|| anyhow!("get empty response from start sink request"))??; | ||
.ok_or_else(|| anyhow!("get empty response from firstrequest"))??; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo
I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.
What's changed and what's your intention?
Currently the jni stream handle of remote sink writer and coordinator is a copy of the original bidi stream handle. In this PR we remove the duplicated code and reuse the original bidi stream.
Besides, we improve the error handling when we call jni methods.
Checklist
./risedev check
(or alias,./risedev c
)Documentation
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.