Skip to content

[$80] Challenge Refactor - Race condition issue #253

Closed
@rootelement

Description

@rootelement

When a user registers:

  1. They click Register on the site
  2. The site POSTs /resources {challengeId, memberId, roleId}
  3. Resource API writes to Dynamo, posts a bus message that a resource has been created

Two things happen at the same time:

  1. resource-processor-es picks up that message and writes the new resource to ES
  2. challenge-processor-es picks up that message and queries GET /resources?challengeId&roleId to get the count to update numOfRegistrants on the challenge object.

The symptom of this is that the user is registered and shows up in the registration list fine, but the numOfRegistrants on the challenge object in es is only right about half the time.

I see two options:

  1. Create a lifecycle for an object, where an API will post a bus message in the present tense, and a processor will post a message in the past tense.
    • For example: if you POST /resource { challengeId, roleId, memberId } the API will create that object in dynamo and post a bus message challenge.resource.action.create. The ES processor will pick that up, do what it needs to, and post a bus message challenge.resource.action.created. Then listeners can pick up on the appropriate timing.
  2. Write directly to ES from the API and post the message as it does now. The resource-processor-es will only be for post-processing of bus messages where necessary.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions