Skip to content

Commit

Permalink
Improve logging.
Browse files Browse the repository at this point in the history
  • Loading branch information
tommie committed Dec 29, 2024
1 parent 209e840 commit cc3c81d
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions syncstorage-mysql/src/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,16 @@ impl MysqlDb {
let modified = SyncTimestamp::from_i64(modified)?;
let now = SyncTimestamp::from_i64(timestamp)?;
// Forbid the write if it would not properly incr the timestamp
warn!("lock check {} {}", modified.as_i64(), now.as_i64());
if modified >= now {
self.rollback_sync().map_err(|err| { warn!("lock rollback {}", &err); err })?;
self.rollback_sync().map_err(|err| {
warn!(
"lock rollback {} {} {}",
modified.as_i64(),
now.as_i64(),
&err
);
err
})?;
return Err(DbError::conflict());
}
self.session
Expand All @@ -242,7 +249,6 @@ impl MysqlDb {
let result = sql_query("SELECT UNIX_TIMESTAMP(UTC_TIMESTAMP(2))*1000 AS timestamp")
.get_result::<TimestampResult>(&mut *self.conn.write().unwrap())
.unwrap();
warn!("lock query {}", result.timestamp);
SyncTimestamp::from_i64(result.timestamp)?
};
self.set_timestamp(timestamp);
Expand Down

0 comments on commit cc3c81d

Please sign in to comment.