forked from mirror/mautrix-discord
Add some debug logs for backfill lock
This commit is contained in:
parent
62a1d83508
commit
07785997bf
3 changed files with 22 additions and 7 deletions
11
backfill.go
11
backfill.go
|
@ -17,7 +17,11 @@ import (
|
|||
)
|
||||
|
||||
func (portal *Portal) forwardBackfillInitial(source *User, thread *Thread) {
|
||||
defer portal.forwardBackfillLock.Unlock()
|
||||
log := portal.log
|
||||
defer func() {
|
||||
log.Debug().Msg("Forward backfill finished, unlocking lock")
|
||||
portal.forwardBackfillLock.Unlock()
|
||||
}()
|
||||
// This should only be called from CreateMatrixRoom which locks forwardBackfillLock before creating the room.
|
||||
if portal.forwardBackfillLock.TryLock() {
|
||||
panic("forwardBackfillInitial() called without locking forwardBackfillLock")
|
||||
|
@ -35,14 +39,14 @@ func (portal *Portal) forwardBackfillInitial(source *User, thread *Thread) {
|
|||
return
|
||||
}
|
||||
|
||||
with := portal.log.With().
|
||||
with := log.With().
|
||||
Str("action", "initial backfill").
|
||||
Str("room_id", portal.MXID.String()).
|
||||
Int("limit", limit)
|
||||
if thread != nil {
|
||||
with = with.Str("thread_id", thread.ID)
|
||||
}
|
||||
log := with.Logger()
|
||||
log = with.Logger()
|
||||
|
||||
portal.backfillLimited(log, source, limit, "", thread)
|
||||
}
|
||||
|
@ -231,7 +235,6 @@ func (portal *Portal) forwardBatchSend(log zerolog.Logger, source *User, message
|
|||
}
|
||||
}
|
||||
portal.bridge.DB.Message.MassInsert(portal.Key, dbMessages)
|
||||
log.Info().Msg("Inserted backfilled batch to database")
|
||||
}
|
||||
|
||||
func (portal *Portal) convertMessageBatch(log zerolog.Logger, source *User, messages []*discordgo.Message, thread *Thread) ([]*event.Event, []*discordgo.Message, []database.Message) {
|
||||
|
|
|
@ -549,13 +549,15 @@ func (portal *Portal) CreateMatrixRoom(user *User, channel *discordgo.Channel) e
|
|||
|
||||
func (portal *Portal) handleDiscordMessages(msg portalDiscordMessage) {
|
||||
if portal.MXID == "" {
|
||||
_, ok := msg.msg.(*discordgo.MessageCreate)
|
||||
msgCreate, ok := msg.msg.(*discordgo.MessageCreate)
|
||||
if !ok {
|
||||
portal.log.Warn().Msg("Can't create Matrix room from non new message event")
|
||||
return
|
||||
}
|
||||
|
||||
portal.log.Debug().Msg("Creating Matrix room from incoming message")
|
||||
portal.log.Debug().
|
||||
Str("message_id", msgCreate.ID).
|
||||
Msg("Creating Matrix room from incoming message")
|
||||
if err := portal.CreateMatrixRoom(msg.user, nil); err != nil {
|
||||
portal.log.Err(err).Msg("Failed to create portal room")
|
||||
return
|
||||
|
|
12
user.go
12
user.go
|
@ -1199,11 +1199,21 @@ func (user *User) pushPortalMessage(msg interface{}, typeName, channelID, guildI
|
|||
return
|
||||
}
|
||||
|
||||
portal.discordMessages <- portalDiscordMessage{
|
||||
wrappedMsg := portalDiscordMessage{
|
||||
msg: msg,
|
||||
user: user,
|
||||
thread: thread,
|
||||
}
|
||||
select {
|
||||
case portal.discordMessages <- wrappedMsg:
|
||||
default:
|
||||
user.log.Warn().
|
||||
Str("discord_event", typeName).
|
||||
Str("guild_id", guildID).
|
||||
Str("channel_id", channelID).
|
||||
Msg("Portal message buffer is full")
|
||||
portal.discordMessages <- wrappedMsg
|
||||
}
|
||||
}
|
||||
|
||||
type CustomReadReceipt struct {
|
||||
|
|
Loading…
Reference in a new issue