From befefe8d84c9e3ecab5bea9292172372289c9678 Mon Sep 17 00:00:00 2001 From: Heikki Linnakangas Date: Wed, 14 Jul 2021 20:00:40 +0100 Subject: [PATCH] Run 'cargo fmt'. Fixes a few formatting discrepancies had crept in recently. --- control_plane/src/compute.rs | 4 +--- control_plane/src/storage.rs | 8 +++++--- pageserver/src/object_repository.rs | 7 ++++++- pageserver/src/repository.rs | 7 ++----- postgres_ffi/src/xlog_utils.rs | 4 ++-- vendor/postgres | 2 +- walkeeper/src/receive_wal.rs | 7 ++----- zenith_utils/src/connstring.rs | 30 +++++++++++++++++++++++------ 8 files changed, 43 insertions(+), 26 deletions(-) diff --git a/control_plane/src/compute.rs b/control_plane/src/compute.rs index b43d6f1fcc..8ef12d3512 100644 --- a/control_plane/src/compute.rs +++ b/control_plane/src/compute.rs @@ -297,9 +297,7 @@ impl PostgresNode { "shared_preload_libraries = zenith \n\ zenith.page_server_connstring = 'host={} port={}'\n\ zenith.zenith_timeline='{}'\n", - host, - port, - self.timelineid + host, port, self.timelineid ), )?; diff --git a/control_plane/src/storage.rs b/control_plane/src/storage.rs index f86bf66e16..3f73ceccc6 100644 --- a/control_plane/src/storage.rs +++ b/control_plane/src/storage.rs @@ -1,5 +1,5 @@ use std::collections::HashMap; -use std::net::{TcpStream}; +use std::net::TcpStream; use std::path::PathBuf; use std::process::Command; use std::thread; @@ -12,8 +12,8 @@ use postgres::{Config, NoTls}; use crate::local_env::LocalEnv; use crate::read_pidfile; -use zenith_utils::connstring::connection_address; use pageserver::branches::BranchInfo; +use zenith_utils::connstring::connection_address; // // Control routines for pageserver. @@ -36,7 +36,9 @@ impl PageServerNode { } fn default_config() -> Config { - "postgresql://no_user@localhost:64000/no_db".parse().unwrap() + "postgresql://no_user@localhost:64000/no_db" + .parse() + .unwrap() } pub fn connection_config(&self) -> Config { diff --git a/pageserver/src/object_repository.rs b/pageserver/src/object_repository.rs index e3bb4ceba9..b9003c13e2 100644 --- a/pageserver/src/object_repository.rs +++ b/pageserver/src/object_repository.rs @@ -642,7 +642,12 @@ impl ObjectTimeline { return Ok(page_img); } static ZERO_PAGE: [u8; 8192] = [0u8; 8192]; - trace!("page {} blk {} at {} not found", tag.rel, tag.blknum, req_lsn); + trace!( + "page {} blk {} at {} not found", + tag.rel, + tag.blknum, + req_lsn + ); Ok(Bytes::from_static(&ZERO_PAGE)) /* return Err("could not find page image")?; */ } diff --git a/pageserver/src/repository.rs b/pageserver/src/repository.rs index 5fed8e9c0e..4ea75f64e3 100644 --- a/pageserver/src/repository.rs +++ b/pageserver/src/repository.rs @@ -479,7 +479,7 @@ mod tests { // Create another relation let buftag2 = BufferTag { rel: TESTREL_B, - blknum : 0, + blknum: 0, }; tline.put_page_image(buftag2, Lsn(2), TEST_IMG("foobar blk 0 at 2"))?; @@ -509,10 +509,7 @@ mod tests { TEST_IMG("foobar blk 0 at 2") ); - assert_eq!( - newtline.get_rel_size(TESTREL_B, Lsn(4))?, - 1 - ); + assert_eq!(newtline.get_rel_size(TESTREL_B, Lsn(4))?, 1); Ok(()) } diff --git a/postgres_ffi/src/xlog_utils.rs b/postgres_ffi/src/xlog_utils.rs index 127e8afbf3..640f9f8803 100644 --- a/postgres_ffi/src/xlog_utils.rs +++ b/postgres_ffi/src/xlog_utils.rs @@ -91,8 +91,8 @@ pub fn get_current_timestamp() -> TimestampTz { match SystemTime::now().duration_since(SystemTime::UNIX_EPOCH) { Ok(n) => { ((n.as_secs() - ((POSTGRES_EPOCH_JDATE - UNIX_EPOCH_JDATE) * SECS_PER_DAY)) - * USECS_PER_SEC - + n.subsec_micros() as u64) as i64 + * USECS_PER_SEC + + n.subsec_micros() as u64) as i64 } Err(_) => panic!("SystemTime before UNIX EPOCH!"), } diff --git a/vendor/postgres b/vendor/postgres index a08f50cba2..40465243d6 160000 --- a/vendor/postgres +++ b/vendor/postgres @@ -1 +1 @@ -Subproject commit a08f50cba293fff045cb771f8c6bb23b89f4f7f7 +Subproject commit 40465243d6441e8085071396102953a6bc5e060b diff --git a/walkeeper/src/receive_wal.rs b/walkeeper/src/receive_wal.rs index ae8d3a6349..15626bd360 100644 --- a/walkeeper/src/receive_wal.rs +++ b/walkeeper/src/receive_wal.rs @@ -6,7 +6,6 @@ use anyhow::{bail, Result}; use log::*; use postgres::{Client, Config, NoTls}; use serde::{Deserialize, Serialize}; -use zenith_utils::connstring::connection_host_port; use std::cmp::{max, min}; use std::fs::{self, File, OpenOptions}; use std::io::{BufReader, Read, Seek, SeekFrom, Write}; @@ -16,6 +15,7 @@ use std::sync::Arc; use std::thread; use std::thread::sleep; use zenith_utils::bin_ser::LeSer; +use zenith_utils::connstring::connection_host_port; use zenith_utils::lsn::Lsn; use crate::replication::HotStandbyFeedback; @@ -159,10 +159,7 @@ fn request_callback(conf: WalAcceptorConf, timelineid: ZTimelineId) { let (host, port) = connection_host_port(&me_conf); let callme = format!( "callmemaybe {} host={} port={} options='-c ztimelineid={}'", - timelineid, - host, - port, - timelineid + timelineid, host, port, timelineid ); loop { info!( diff --git a/zenith_utils/src/connstring.rs b/zenith_utils/src/connstring.rs index 1340f0b899..cda8eeac86 100644 --- a/zenith_utils/src/connstring.rs +++ b/zenith_utils/src/connstring.rs @@ -1,8 +1,16 @@ use postgres::Config; pub fn connection_host_port(config: &Config) -> (String, u16) { - assert_eq!(config.get_hosts().len(), 1, "only one pair of host and port is supported in connection string"); - assert_eq!(config.get_ports().len(), 1, "only one pair of host and port is supported in connection string"); + assert_eq!( + config.get_hosts().len(), + 1, + "only one pair of host and port is supported in connection string" + ); + assert_eq!( + config.get_ports().len(), + 1, + "only one pair of host and port is supported in connection string" + ); let host = match &config.get_hosts()[0] { postgres::config::Host::Tcp(host) => host.as_ref(), postgres::config::Host::Unix(host) => host.to_str().unwrap(), @@ -21,14 +29,24 @@ mod tests { #[test] fn test_connection_host_port() { - let config: Config = "postgresql://no_user@localhost:64000/no_db".parse().unwrap(); - assert_eq!(connection_host_port(&config), ("localhost".to_owned(), 64000)); + let config: Config = "postgresql://no_user@localhost:64000/no_db" + .parse() + .unwrap(); + assert_eq!( + connection_host_port(&config), + ("localhost".to_owned(), 64000) + ); } #[test] #[should_panic(expected = "only one pair of host and port is supported in connection string")] fn test_connection_host_port_multiple_ports() { - let config: Config = "postgresql://no_user@localhost:64000,localhost:64001/no_db".parse().unwrap(); - assert_eq!(connection_host_port(&config), ("localhost".to_owned(), 64000)); + let config: Config = "postgresql://no_user@localhost:64000,localhost:64001/no_db" + .parse() + .unwrap(); + assert_eq!( + connection_host_port(&config), + ("localhost".to_owned(), 64000) + ); } }