Skip to content

Commit

Permalink
drop shard cache when wiping user data from carstore
Browse files Browse the repository at this point in the history
  • Loading branch information
whyrusleeping committed Sep 29, 2023
1 parent 9cd7059 commit b320b8a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
4 changes: 3 additions & 1 deletion bgs/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -506,5 +506,7 @@ func (bgs *BGS) handleAdminResetRepo(e echo.Context) error {
return err
}

return nil
return e.JSON(200, map[string]any{
"success": true,
})
}
4 changes: 2 additions & 2 deletions bgs/bgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,15 +281,15 @@ func (bgs *BGS) StartWithListener(listen net.Listener) error {
sendHeader = false
}

log.Warnf("HANDLER ERROR: (%s) %s", ctx.Path(), err)

if strings.HasPrefix(ctx.Path(), "/admin/") {
ctx.JSON(500, map[string]any{
"error": err.Error(),
})
return
}

log.Warnf("HANDLER ERROR: (%s) %s", ctx.Path(), err)

if sendHeader {
ctx.Response().WriteHeader(500)
}
Expand Down
9 changes: 9 additions & 0 deletions carstore/bs.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,13 @@ func (cs *CarStore) checkLastShardCache(user models.Uid) *CarShard {
return nil
}

func (cs *CarStore) removeLastShardCache(user models.Uid) {
cs.lscLk.Lock()
defer cs.lscLk.Unlock()

delete(cs.lastShardCache, user)
}

func (cs *CarStore) putLastShardCache(ls *CarShard) {
cs.lscLk.Lock()
defer cs.lscLk.Unlock()
Expand Down Expand Up @@ -963,6 +970,8 @@ func (cs *CarStore) WipeUserData(ctx context.Context, user models.Uid) error {
}
}

cs.removeLastShardCache(user)

return nil
}

Expand Down
2 changes: 1 addition & 1 deletion repomgr/repomgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,7 @@ func (rm *RepoManager) ImportNewRepo(ctx context.Context, user models.Uid, repoD

diffops, err := r.DiffSince(ctx, curhead)
if err != nil {
return fmt.Errorf("diff trees: %w", err)
return fmt.Errorf("diff trees (curhead: %s): %w", curhead, err)
}

var ops []RepoOp
Expand Down

0 comments on commit b320b8a

Please sign in to comment.