Skip to content

Conversation

@blam23
Copy link
Contributor

@blam23 blam23 commented Jul 20, 2021

No description provided.

@blam23 blam23 requested a review from kthomas July 20, 2021 22:20
Copy link
Contributor

@kthomas kthomas left a comment

Choose a reason for hiding this comment

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

This makes sense with regard to cardinality 👍🏻

IIRC it was always implemented in the way you describe.


payload, _ := json.Marshal(fragment.Reassembly)
err = natsutil.NatsPublish(natsPacketReassembleSubject, payload)
remaining := fragment.Cardinality - *i
Copy link
Contributor

@kthomas kthomas Jul 20, 2021

Choose a reason for hiding this comment

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

I think this breaks parallelization pretty badly...

We must use an atomic counter here. You can receive all 1000 chunks of a 1000-chunk packet at the same time. Then you are racing for the last one to finish, and whatever cardinality i was is now responsible for setting progress....

This was meant to suggest using an atomic decrement equivalent to remaining--.

Copy link
Contributor Author

@blam23 blam23 Jul 21, 2021

Choose a reason for hiding this comment

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

Not sure I'm following - i here is the redis counter that's atomically incremented when we ingest a fragment.
I should probably rename it, but all this is there for is making sure we send out only one prvd.packet.reassemble.finalize message and only once we've recieved all fragments.

Only concurrency issue here that I can see is that there is a possibility we recieve the last fragment at the same time as the reassembly header in which case we'd run this twice - I am fixing that now (just need to increment on the header and check for (Cardinality + 1) - counter

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm

@blam23 blam23 marked this pull request as ready for review July 26, 2021 13:32
@kthomas
Copy link
Contributor

kthomas commented Sep 4, 2021

@blam23 is this still considered WIP?

@blam23 blam23 changed the title [WIP] Implement nchain/consumer Implement nchain/consumer Sep 4, 2021
@blam23
Copy link
Contributor Author

blam23 commented Sep 4, 2021

No this code is in a good state and can be reviewed/merged - although I'm not sure if it's being merged here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants