From dfe216466da41581cae084e19db2b43fcf8fca77 Mon Sep 17 00:00:00 2001 From: Philip Jenvey Date: Tue, 26 Aug 2025 12:08:47 -0700 Subject: [PATCH] fix: Revert "fix: mysql: Call set_timestamp in lock_for_write_sync." This reverts commit d6c0b9efc68111d6a433e7b618dde789ba5377d6. --- syncstorage-mysql/src/models.rs | 28 +++++----------------------- 1 file changed, 5 insertions(+), 23 deletions(-) diff --git a/syncstorage-mysql/src/models.rs b/syncstorage-mysql/src/models.rs index a20cb0e5..4781792f 100644 --- a/syncstorage-mysql/src/models.rs +++ b/syncstorage-mysql/src/models.rs @@ -212,36 +212,24 @@ impl MysqlDb { // Lock the db self.begin(true)?; - // SyncTimestamp only has 10 ms resolution. - let result = user_collections::table - .select(( - sql::("UNIX_TIMESTAMP(UTC_TIMESTAMP(2))*1000"), - user_collections::modified, - )) + let modified = user_collections::table + .select(user_collections::modified) .filter(user_collections::user_id.eq(user_id)) .filter(user_collections::collection_id.eq(collection_id)) .for_update() .first(&mut *self.conn.write()?) .optional()?; - let timestamp = if let Some((timestamp, modified)) = result { + if let Some(modified) = modified { let modified = SyncTimestamp::from_i64(modified)?; - let now = SyncTimestamp::from_i64(timestamp)?; // Forbid the write if it would not properly incr the timestamp - if modified >= now { + if modified >= self.timestamp() { return Err(DbError::conflict()); } self.session .borrow_mut() .coll_modified_cache .insert((user_id as u32, collection_id), modified); - now - } else { - let result = sql_query("SELECT UNIX_TIMESTAMP(UTC_TIMESTAMP(2))*1000 AS timestamp") - .get_result::(&mut *self.conn.write()?)?; - SyncTimestamp::from_i64(result.timestamp)? - }; - self.set_timestamp(timestamp); - + } self.session .borrow_mut() .coll_locks @@ -1155,12 +1143,6 @@ struct NameResult { name: String, } -#[derive(Debug, QueryableByName)] -struct TimestampResult { - #[diesel(sql_type = BigInt)] - timestamp: i64, -} - #[derive(Debug, QueryableByName)] struct UserCollectionsResult { // Can't substitute column names here.