Skip to content

fix(async-csv): Finishing touches on some async-csv bugs#18349

Merged
leeandher merged 6 commits into
masterfrom
leander/better-response
Apr 21, 2020
Merged

fix(async-csv): Finishing touches on some async-csv bugs#18349
leeandher merged 6 commits into
masterfrom
leander/better-response

Conversation

@leeandher

@leeandher leeandher commented Apr 17, 2020

Copy link
Copy Markdown
Member

This PR is aimed at fixing up 4 smaller tasks.

  1. When the user refreshes the page and clicks 'Export' again, we return a 200 (not a 201) because we didn't queue up another export. We just found their previous. Instead of swallowing this, the user now receives a different toast notification

  2. As this will feature will likely go to GA soon, we're going to temporarily enforce a hard limit on file sizes at 1M rows.

  3. The 404 response from the server doesn't have a responseJSON field. This change should still render an alright UI in case this happens (resolves JAVASCRIPT-222B)

  4. Increase the number of entries written to the CSV every iteration from 1000 to something higher. I just set it to 50000 10000 as a safety net.

@leeandher leeandher self-assigned this Apr 17, 2020

@instrumented_task(name="sentry.data_export.tasks.assemble_download", queue="data_export")
def assemble_download(data_export_id, limit=None, environment_id=None):
def assemble_download(data_export_id, limit=1000000, environment_id=None):

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is point 2. Enforces a hard limit of 1M rows

Comment on lines +49 to +64
const [data, _, response] = await api.requestPromise(
`/organizations/${slug}/data-export/`,
{
includeAllArgs: true,
method: 'POST',
data: {
query_type: queryType,
query_info: queryInfo,
},
}
);
const {id: dataExportId} = data;
addSuccessMessage(
t("Sit tight. We'll shoot you an email when your data is ready for download.")
response?.status === 201
? t("Sit tight. We'll shoot you an email when your data is ready for download.")
: t("It looks like we're already working on it. Sit tight, we'll email you.")

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is Point 1. Show a different toast message when the user refreshes the page and tries the same download. (There is a ticket to eventually save the state across refreshes, but it proves a little more difficult, so this is a temp fix)

<Body>
<p>{errDetail}</p>
</Body>
)}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is Point 3. If there isn't an error message, don't show this body section (as is the case in 404s)

@leeandher leeandher requested a review from a team April 17, 2020 22:07
Comment thread src/sentry/data_export/base.py Outdated
from enum import Enum

SNUBA_MAX_RESULTS = 1000
SNUBA_MAX_RESULTS = 50000

@leeandher leeandher Apr 20, 2020

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is Point 4. Allow for more results per iteration (speeds up task by 50x). I believe the only limitation maybe memory issues by have a list that long with dicts in every spot. Not entirely sure on the memory limitations of workers in production so I think this is a good spot for now.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Changed to 10k, since that's the actual max result limit. My bad!

@leeandher leeandher changed the title fix(async-csv): Better communicate 200s to users, enforce file-size limit, and fix error rendering fix(async-csv): Finishing touches on some async-csv bugs Apr 21, 2020
@leeandher leeandher merged commit 082000a into master Apr 21, 2020
@leeandher leeandher deleted the leander/better-response branch April 21, 2020 21:01
@github-actions github-actions Bot locked and limited conversation to collaborators Dec 19, 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.

2 participants