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

Bump similar_asserts to 1.6 #4269

Merged
merged 2 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ jobs:
run: |
sudo systemctl start mysql.service
mysql -e "create database diesel_test; create database diesel_unit_test; grant all on \`diesel_%\`.* to 'root'@'localhost';" -uroot -proot
echo "MYSQL_DATABASE_URL=mysql://root:root@localhost/diesel_test" >> $GITHUB_ENV
echo "MYSQL_EXAMPLE_DATABASE_URL=mysql://root:root@localhost/diesel_example" >> $GITHUB_ENV
echo "MYSQL_UNIT_TEST_DATABASE_URL=mysql://root:root@localhost/diesel_unit_test" >> $GITHUB_ENV
echo "MYSQL_DATABASE_URL=mysql://root:root@127.0.0.1/diesel_test" >> $GITHUB_ENV
echo "MYSQL_EXAMPLE_DATABASE_URL=mysql://root:root@127.0.0.1/diesel_example" >> $GITHUB_ENV
echo "MYSQL_UNIT_TEST_DATABASE_URL=mysql://root:root@127.0.0.1/diesel_unit_test" >> $GITHUB_ENV

- name: Install postgres (MacOS)
if: matrix.os == 'macos-13' && matrix.backend == 'postgres'
Expand Down Expand Up @@ -227,7 +227,8 @@ jobs:

- name: Run tests
shell: bash
run: cargo xtask run-tests ${{ matrix.backend }} $NO_DOC_TESTS $EXAMPLE_SCHEMA_CHECKS -- --no-fail-fast $FLAGS
run: |
cargo xtask run-tests ${{ matrix.backend }} $NO_DOC_TESTS $EXAMPLE_SCHEMA_CHECKS -- --no-fail-fast $FLAGS

- name: Run diesel_benches
if: runner.os == 'Linux'
Expand Down
4 changes: 4 additions & 0 deletions diesel/src/r2d2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,7 @@ mod tests {
use std::sync::mpsc;
use std::sync::Arc;
use std::thread;
use std::time::Duration;

use crate::r2d2::*;
use crate::test_helpers::*;
Expand Down Expand Up @@ -636,6 +637,9 @@ mod tests {
assert_eq!(release_count.load(Ordering::Relaxed), 2);
assert_eq!(checkin_count.load(Ordering::Relaxed), 3);
assert_eq!(checkout_count.load(Ordering::Relaxed), 3);
// this is required to workaround a segfault while shutting down
// the pool
std::thread::sleep(Duration::from_millis(100));
Copy link

Choose a reason for hiding this comment

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

This is unfortunate. Do we know what we're waiting for? A timed delay like this has the potential to be unreliable, e.g., if the test system is slow for some reason. If possible it would be best to wait in a loop, testing for whatever condition is needed to avoid the segfault.

Copy link
Member Author

Choose a reason for hiding this comment

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

You are correct that this is not great. Unfortunately I do not know what exactly we are waiting for, just that waiting seems to resolve the segfaults. My guess is that there is something happening in parallel here that causes the segfault. R2d2 is acquiring a new connection, while the pool is shutting down it might just be that openssl cannot handle creating/dropping a connection in a fast turnaround? Or that it returns early but does stuff on it's own in the background, which in turn leads to collisions while shutting down the connection?
Given that I did not found a way to reproduce the problem locally it's relatively hard for me to debug it. I just went for the first thing that seem to resolve the issue to unblock the other PR's for now. If someone has a better solution I'm more than happy to accept that.

}

#[cfg(feature = "postgres")]
Expand Down
2 changes: 1 addition & 1 deletion diesel_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ syn = { version = "2", features = ["visit"] }
tracing = "0.1"
tracing-subscriber = { version = "0.3.10", features = ["env-filter"] }
thiserror = "1.0.10"
similar-asserts = "1.5.0"
similar-asserts = "1.6.0"

[dependencies.diesel]
version = "~2.2.0"
Expand Down
6 changes: 2 additions & 4 deletions diesel_cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,13 +283,11 @@ fn regenerate_schema_if_file_specified(matches: &ArgMatches) -> Result<(), crate
.map_err(|e| crate::errors::Error::IoError(e, Some(path.to_owned())))?;

if schema.lines().ne(old_buf.lines()) {
// it's fine to leak here, we will
// exit the application anyway soon
let label = path.file_name().expect("We have a file name here");
let label = label.to_string_lossy().into_owned().leak();
let label = label.to_string_lossy();
weiznich marked this conversation as resolved.
Show resolved Hide resolved
println!(
"{}",
SimpleDiff::from_str(&old_buf, &schema, label, "new schema")
SimpleDiff::from_str(&old_buf, &schema, &label, "new schema")
);
return Err(crate::errors::Error::SchemaWouldChange(
path.display().to_string(),
Expand Down
Loading