Skip to content

Conversation

@untitaker
Copy link
Member

@untitaker untitaker commented Oct 27, 2020

Works on my machine!

  • write extra tests around retained data
  • create activity item in new group for reprocessing
  • create groupredirect

_REDIS_SYNC_TTL = 3600


GROUP_MODELS_TO_MIGRATE = GROUP_RELATED_MODELS + (models.Activity,)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After #21611 this addition should not be necessary

@github-actions
Copy link
Contributor

github-actions bot commented Oct 27, 2020

size-limit report

Path Size
public/app.js 241.02 KB (0%)
public/vendor.js 445.71 KB (0%)

@github-actions
Copy link
Contributor

github-actions bot commented Oct 27, 2020

This PR has a migration; here is the generated SQL

--
-- Alter field type on activity
--

group.short_id = None # satisfy unique constraint
group.save()

group.pk = group.id = None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be worth having a comment here that you're tricking django into doing an INSERT.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

project_id=group.project_id,
group_id=group.id,
max_events=max_events,
acting_user_id=request.user.id,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's be very careful with this. The user can be a Sentry app or also None, in case this is being executed via certain auth tokens. It's probably worth checking for the existence of a user before accessing .id.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we sure there's no request user in certain situations? I thought auth tokens are attached to users. It's kinda undesirable to have no idea who triggered a reprocessing.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jan says request.user could be SentryApp, fixed

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fwiw I quickly tried setting up integration platform locally to test this, but I failed (getting csrf issues)

from ..base import BaseDeletionTask, BaseRelation, ModelDeletionTask, ModelRelation


GROUP_RELATED_MODELS = (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Since this is now used outside of deletions, can we move this to a better place, for instance somewhere in sentry.models? This could even be on Group itself.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Despite the name this is still related to group deletion and the order of items is specific to deletion. I was also considering duplicating the list like group merge/unmerge does. Let me know what you prefer.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, I'll leave this up to you. I found it interesting that this is being imported from reprocessing to copy over information rather than delete it, that's all.

transferred_group_attrs[attr] = getattr(group, attr)

group.status = models.GroupStatus.REPROCESSING
group.short_id = None # satisfy unique constraint
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this relies on Postgres specific behavior, which is fine now that we only support postgres.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the pg specific behavior? I can add a comment

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That NULL is excluded from unique constraints. AFAIK, MSSQL does enforce this, but I might be wrong.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes. I added a comment. This slipped past me.

def start_group_reprocessing(project_id, group_id, max_events=None, acting_user_id=None):
from django.db import transaction

with transaction.atomic():
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw this might be a pretty large transaction, it touches a lot of tables at once.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's follow up on this please. I'm pretty sure we'll want to back this out.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is that I would really not like to fail halfway through, because that's quite a mess to clean up. Perhaps we want some shitty kind of "clientside rollback", I think I saw that someplace else already.

def start_group_reprocessing(project_id, group_id, max_events=None, acting_user_id=None):
from django.db import transaction

with transaction.atomic():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's follow up on this please. I'm pretty sure we'll want to back this out.

@untitaker untitaker merged commit 7a5c99b into master Oct 28, 2020
@untitaker untitaker deleted the ref/reprocessing-retain-data branch October 28, 2020 15:52
@github-actions github-actions bot locked and limited conversation to collaborators Dec 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants