fix: sync correct collectible username projection
This commit is contained in:
parent
8356989e01
commit
9041abd3d3
42 changed files with 601 additions and 758 deletions
|
|
@ -1307,24 +1307,6 @@ func (m *SessionManager) ReceivesUpdatesForAuthKey(authKeyID [8]byte, sessionID
|
|||
return hasProfile && c.receivesUpdates.Load() && c.membershipsSynced.Load()
|
||||
}
|
||||
|
||||
// UpdatesActivationStartedForAuthKey reports whether the session has completed
|
||||
// membership synchronization and either became ready or is draining its older
|
||||
// pending FIFO. Unlike ReceivesUpdatesForAuthKey, flushing is a positive result:
|
||||
// another delivery callback must not rebuild memberships or enqueue a duplicate
|
||||
// cache-convergence update behind the same pending batch.
|
||||
func (m *SessionManager) UpdatesActivationStartedForAuthKey(authKeyID [8]byte, sessionID int64) bool {
|
||||
m.mu.RLock()
|
||||
key := sessionKey{authKeyID: authKeyID, sessionID: sessionID}
|
||||
c, ok := m.bySession[key]
|
||||
flushing := m.flushing[key]
|
||||
m.mu.RUnlock()
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
_, hasProfile := c.LayerProfile()
|
||||
return hasProfile && c.membershipsSynced.Load() && (c.receivesUpdates.Load() || flushing)
|
||||
}
|
||||
|
||||
// SetReceivesUpdatesForAuthKey 标记指定 raw auth_key_id + session_id 是否接收主动 updates。
|
||||
func (m *SessionManager) SetReceivesUpdatesForAuthKey(authKeyID [8]byte, sessionID int64, receives bool) {
|
||||
m.mu.Lock()
|
||||
|
|
|
|||
|
|
@ -26,36 +26,11 @@ func TestReceivesUpdatesForAuthKeyRequiresMembershipSync(t *testing.T) {
|
|||
if sm.ReceivesUpdatesForAuthKey(raw, 42) {
|
||||
t.Fatal("ready before membership sync — a failed sync would never be retried")
|
||||
}
|
||||
if sm.UpdatesActivationStartedForAuthKey(raw, 42) {
|
||||
t.Fatal("activation started before membership sync")
|
||||
}
|
||||
|
||||
sm.SetSessionChannelMemberships(raw, 42, 100, []int64{7}, sm.ChannelMembershipGeneration(raw, 42))
|
||||
if !sm.ReceivesUpdatesForAuthKey(raw, 42) {
|
||||
t.Fatal("not ready after successful membership sync")
|
||||
}
|
||||
if !sm.UpdatesActivationStartedForAuthKey(raw, 42) {
|
||||
t.Fatal("activation not started after successful membership sync")
|
||||
}
|
||||
|
||||
// Pending FIFO drain counts as an activation already in progress even though
|
||||
// the session is not fully ready yet. A stale RPC callback must not enqueue a
|
||||
// duplicate cache-convergence update behind that same FIFO.
|
||||
key := sessionKey{authKeyID: raw, sessionID: 42}
|
||||
sm.mu.Lock()
|
||||
c.receivesUpdates.Store(false)
|
||||
sm.flushing[key] = true
|
||||
sm.mu.Unlock()
|
||||
if sm.ReceivesUpdatesForAuthKey(raw, 42) {
|
||||
t.Fatal("flushing session reported fully ready")
|
||||
}
|
||||
if !sm.UpdatesActivationStartedForAuthKey(raw, 42) {
|
||||
t.Fatal("flushing session did not report activation started")
|
||||
}
|
||||
sm.mu.Lock()
|
||||
delete(sm.flushing, key)
|
||||
c.receivesUpdates.Store(true)
|
||||
sm.mu.Unlock()
|
||||
|
||||
// 没有任何频道的账号:空列表的成功同步同样算就绪。
|
||||
sm.SetSessionChannelMemberships(raw, 42, 100, nil, sm.ChannelMembershipGeneration(raw, 42))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue