diff --git a/Cargo.lock b/Cargo.lock index 8ef24c86a0..8bf9f5250b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1142,7 +1142,7 @@ checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" [[package]] name = "glean" -version = "0.17.12" +version = "0.17.15" dependencies = [ "chrono", "serde 1.0.203", @@ -1241,9 +1241,9 @@ dependencies = [ [[package]] name = "heck" -version = "0.4.1" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "hermit-abi" @@ -2045,15 +2045,15 @@ checksum = "106dd99e98437432fed6519dedecfade6a06a73bb7b2a1e019fdd2bee5778d94" [[package]] name = "pyo3" -version = "0.21.2" +version = "0.22.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5e00b96a521718e08e03b1a622f01c8a8deb50719335de3f60b3b3950f069d8" +checksum = "3d922163ba1f79c04bc49073ba7b32fd5a8d3b76a87c955921234b8e77333c51" dependencies = [ "cfg-if", "indoc", "libc", "memoffset", - "parking_lot", + "once_cell", "portable-atomic", "pyo3-build-config", "pyo3-ffi", @@ -2063,9 +2063,9 @@ dependencies = [ [[package]] name = "pyo3-build-config" -version = "0.21.2" +version = "0.22.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7883df5835fafdad87c0d888b266c8ec0f4c9ca48a5bed6bbb592e8dedee1b50" +checksum = "bc38c5feeb496c8321091edf3d63e9a6829eab4b863b4a6a65f26f3e9cc6b179" dependencies = [ "once_cell", "target-lexicon", @@ -2073,9 +2073,9 @@ dependencies = [ [[package]] name = "pyo3-ffi" -version = "0.21.2" +version = "0.22.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01be5843dc60b916ab4dad1dca6d20b9b4e6ddc8e15f50c47fe6d85f1fb97403" +checksum = "94845622d88ae274d2729fcefc850e63d7a3ddff5e3ce11bd88486db9f1d357d" dependencies = [ "libc", "pyo3-build-config", @@ -2083,9 +2083,9 @@ dependencies = [ [[package]] name = "pyo3-macros" -version = "0.21.2" +version = "0.22.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77b34069fc0682e11b31dbd10321cbf94808394c56fd996796ce45217dfac53c" +checksum = "e655aad15e09b94ffdb3ce3d217acf652e26bbc37697ef012f5e5e348c716e5e" dependencies = [ "proc-macro2", "pyo3-macros-backend", @@ -2095,9 +2095,9 @@ dependencies = [ [[package]] name = "pyo3-macros-backend" -version = "0.21.2" +version = "0.22.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08260721f32db5e1a5beae69a55553f56b99bd0e1c3e6e0a5e8851a9d0f5a85c" +checksum = "ae1e3f09eecd94618f60a455a23def79f79eba4dc561a97324bf9ac8c6df30ce" dependencies = [ "heck", "proc-macro2", diff --git a/syncserver/src/web/handlers.rs b/syncserver/src/web/handlers.rs index 4af2259f8d..c1827ed822 100644 --- a/syncserver/src/web/handlers.rs +++ b/syncserver/src/web/handlers.rs @@ -40,34 +40,33 @@ pub async fn get_collections( request: HttpRequest, state: Data, ) -> Result { - if state.glean_enabled { - // Values below are be passed to the Glean logic to emit metrics. - // This is used to measure DAU (Daily Active Use) of Sync. - let user_agent = request - .headers() - .get(header::USER_AGENT) - .and_then(|header| header.to_str().ok()) - .unwrap_or(""); - let device_info: DeviceInfo = get_device_info(user_agent); - - state.glean_logger.record_events_ping( - &RequestInfo { - user_agent: user_agent.to_owned(), - ip_address: "".to_owned(), - }, - &EventsPing { - syncstorage_device_family: device_info.device_family.to_string(), - syncstorage_hashed_device_id: meta.user_id.hashed_device_id.clone(), - syncstorage_hashed_fxa_uid: meta.user_id.hashed_fxa_uid.clone(), - syncstorage_platform: device_info.platform.to_string(), - event: Some(Box::new(SyncstorageGetCollectionsEvent {})), - }, - ); - } - db_pool - .transaction_http(request, |db| async move { + .transaction_http(request.clone(), |db| async move { meta.emit_api_metric("request.get_collections"); + if state.glean_enabled { + // Values below are be passed to the Glean logic to emit metrics. + // This is used to measure DAU (Daily Active Use) of Sync. + let user_agent = request + .headers() + .get(header::USER_AGENT) + .and_then(|header| header.to_str().ok()) + .unwrap_or(""); + let device_info: DeviceInfo = get_device_info(user_agent); + + state.glean_logger.record_events_ping( + &RequestInfo { + user_agent: user_agent.to_owned(), + ip_address: "".to_owned(), + }, + &EventsPing { + syncstorage_device_family: device_info.device_family.to_string(), + syncstorage_hashed_device_id: meta.user_id.hashed_device_id.clone(), + syncstorage_hashed_fxa_uid: meta.user_id.hashed_fxa_uid.clone(), + syncstorage_platform: device_info.platform.to_string(), + event: Some(Box::new(SyncstorageGetCollectionsEvent {})), + }, + ); + } let result = db.get_collection_timestamps(meta.user_id).await?; Ok(HttpResponse::build(StatusCode::OK) diff --git a/syncstorage-db-common/src/util.rs b/syncstorage-db-common/src/util.rs index 97350eee6e..4e2858a634 100644 --- a/syncstorage-db-common/src/util.rs +++ b/syncstorage-db-common/src/util.rs @@ -1,4 +1,4 @@ -use std::{convert::TryInto, u64}; +use std::convert::TryInto; use chrono::{ offset::{FixedOffset, TimeZone, Utc}, diff --git a/syncstorage-spanner/src/models.rs b/syncstorage-spanner/src/models.rs index 8e6a636f8c..f270962b38 100644 --- a/syncstorage-spanner/src/models.rs +++ b/syncstorage-spanner/src/models.rs @@ -1292,11 +1292,7 @@ impl SpannerDb { // most databases) so we specify a max value with offset subtracted // to avoid overflow errors (that only occur w/ a FORCE_INDEX= // directive) OutOfRange: 400 int64 overflow: + offset - query = format!( - "{} LIMIT {}", - query, - i64::max_value() - offset.offset as i64 - ); + query = format!("{} LIMIT {}", query, i64::MAX - offset.offset as i64); }; if let Some(offset) = params.offset { diff --git a/tokenserver-auth/Cargo.toml b/tokenserver-auth/Cargo.toml index 5ee8f95e7b..7dacffafcc 100644 --- a/tokenserver-auth/Cargo.toml +++ b/tokenserver-auth/Cargo.toml @@ -28,7 +28,7 @@ syncserver-common = { path = "../syncserver-common" } tokenserver-common = { path = "../tokenserver-common" } tokenserver-settings = { path = "../tokenserver-settings" } tokio = { workspace = true } -pyo3 = { version = "0.21", features = ["auto-initialize"], optional = true } +pyo3 = { version = "0.22", features = ["auto-initialize"], optional = true } [dev-dependencies] diff --git a/tokenserver-auth/src/oauth/py.rs b/tokenserver-auth/src/oauth/py.rs index d6f0c45b12..3569b3f777 100644 --- a/tokenserver-auth/src/oauth/py.rs +++ b/tokenserver-auth/src/oauth/py.rs @@ -19,9 +19,8 @@ use std::{sync::Arc, time::Duration}; /// The verifier used to verify OAuth tokens. #[derive(Clone)] pub struct Verifier { - // Note that we do not need to use an Arc here, since Py is already a reference-counted // pointer - inner: Py, + inner: Arc>, timeout: u64, blocking_threadpool: Arc, } @@ -103,7 +102,7 @@ impl Verifier { })?; Ok(Self { - inner, + inner: Arc::new(inner), timeout: settings.fxa_oauth_request_timeout, blocking_threadpool, })