Skip to content

Commit bb98cfc

Browse files
authored
simple fix to gregor CI clock skew bug (keybase#4793)
* simple fix to gregor CI clock skew bug * also revert clock skew change
1 parent 971c533 commit bb98cfc

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

‎go/gregor/storage/mem_sm.go‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ type item struct {
4242
item gregor.Item
4343
ctime time.Time
4444
dtime *time.Time
45+
46+
// If we received a message from the server that a message should be dimissed,
47+
// do so immediately, so as not to introduce clock-skew bugs. We previously
48+
// had a bug here --- a message would come in to dismiss a message M at server time T,
49+
// but then we would wait around for S seconds before marking that message as
50+
// dismissed, where S is the clock skew between the client and server. This seems
51+
// unnecessary, we should just mark the message dismissed when it comes in.
52+
dismissedImmediate bool
4553
}
4654

4755
// loggedMsg is a message that we've logged on arrival into this state machine
@@ -60,8 +68,12 @@ type user struct {
6068
log []loggedMsg
6169
}
6270

63-
// isDismissedAt returns true if item i is dismissed at time t
71+
// isDismissedAt returns true if item i is dismissed at time t. It will always return
72+
// true if the `dismissedImmediate` flag was turned out.
6473
func (i item) isDismissedAt(t time.Time) bool {
74+
if i.dismissedImmediate {
75+
return true
76+
}
6577
if i.dtime != nil && isBeforeOrSame(*i.dtime, t) {
6678
return true
6779
}
@@ -126,6 +138,7 @@ func (u *user) dismissMsgIDs(now time.Time, ids []gregor.MsgID) {
126138
for _, i := range u.items {
127139
if _, found := set[msgIDtoString(i.item.Metadata().MsgID())]; found {
128140
i.dtime = &now
141+
i.dismissedImmediate = true
129142
}
130143
}
131144
}
@@ -156,6 +169,7 @@ func (u *user) dismissRanges(now time.Time, rs []gregor.MsgRange) {
156169
if r.Category().String() == i.item.Category().String() &&
157170
isBeforeOrSame(i.ctime, toTime(now, r.EndTime())) {
158171
i.dtime = &now
172+
i.dismissedImmediate = true
159173
break
160174
}
161175
}

‎go/systests/rekey_test.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -774,7 +774,7 @@ func (rkt *rekeyTester) confirmGregorStateIsClean() {
774774
defer rkt.log.Debug("- confirmGregorStateIsClean")
775775

776776
start := time.Now()
777-
last := start.Add(30 * time.Second)
777+
last := start.Add(3 * time.Second)
778778
i := 0
779779
var delay time.Duration
780780

0 commit comments

Comments
 (0)