Wednesday, 15 February 2012

c# - Unprocessed items in queue modify DB state - how do I handle concurrent requests for data? -



c# - Unprocessed items in queue modify DB state - how do I handle concurrent requests for data? -

sorry if title little unusual - wasn't sure how condense problem one-liner appropriately!

basically, have queue of messages on scheme a, of received through socket several instances of scheme b , processed 1 one. of these messages modify info in scheme a's database, represents 'global state' (i.e. state of scheme , of scheme b instances).

at same time, instances of scheme b can send 'state request' messages queue, which, when processed, homecoming info scheme a's database requesting scheme b farther processing. operations on 1 instance of scheme b depend on state of 1 or more other instances of scheme b.

obviously, there's info integrity issue here. 'state request' message processed , info returned, there number of unprocessed messages in queue modify global state, rendering returned info unreliable.

after lot of thinking, i'm pretty sure problem cannot solved while global architecture remains way is. there way can restructure overall scheme such no longer problem?

thanks!

one general approach create single info path through system, there fixed upstream-to-downstream info flow, , downstream state can lag upstream, there's no chance indeterminate ordering (race conditions).

towards end, possible rearchitect that:

1) pushes (broadcasts) each b, rather b polling state. identify, polling introduces 2nd path info , allows race conditions.

2) "some ops on 1 b instance depend on other bs" sounds req-reply communicate between bs, introduces alternate info paths , indeterminism. bs peers, there's no obvious upstream among them. but- info striped across bs such piece of data, 1 b master pushes updates concerning datum other bs? example, b1 master a-m, , b2 n-z. piece of info "q", info flow -> b2 -> b1 , deterministic, scheme of record state of system.

if bs coupled - illustration if a-m info depends on n-z data, sequence numbers (assigned on incoming messages) can help distinguish newer older states , prevent old info overwriting newer. details depend on details of b-b interactions.

any eurekas yet?

c# .net producer-consumer

No comments:

Post a Comment