-
Notifications
You must be signed in to change notification settings - Fork 409
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add job to load messages in from a csv and fix some crucial bugs in twilio.js #1346
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would like to test this out on production to see if it resolves our issues.
const countResult = await r.getCount( | ||
r.knex("message").where("service_id", messageInstance.service_id) | ||
); | ||
const [countResult] = await r |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A theory about the failure was that this was getting a count rather than a single message -- it therefore deadlocked on two of the same messages coming in, because it didn't need to find just one, but get a full count.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sense, though it would be good to rename this variable, since it is no longer the count (unless I'm misunderstanding the change).
@@ -56,13 +56,16 @@ async function convertMessagePartsToMessage(messageParts) { | |||
const lastMessage = await getLastMessage({ | |||
contactNumber | |||
}); | |||
if (!lastMessage) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Often SMS spam comes in. If we failed to find a lastMessage, then this failed rather than returning and completing normally -- leaving a db connection open -- and possibly a transaction.
const countResult = await r.getCount( | ||
r.knex("message").where("service_id", messageInstance.service_id) | ||
); | ||
const [countResult] = await r |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sense, though it would be good to rename this variable, since it is no longer the count (unless I'm misunderstanding the change).
This was tested on MoveOn's production instance and solved a data-race issue for DB changes described in https://github.com/MoveOnOrg/Spoke/pull/1311#issuecomment-568786302 |
Fixes # (issue)
Description
This adds a method to run
yarn process-message-csv SOMEMESSAGEFILE.csv
on a file and load them message responses into the database all at once -- this is a useful tool when processing messages from outside the twilio api and/or for testing.In writing this, some critical bugs were found in the current twilio processing that may be causing deadlocks on indexes and other problems. This fixes those minimally, awaiting more fixes in e.g.
Checklist: