database - A Client Walks Into a Server And Asks "What's New?" – Problems With Timestamps -


i'm looking solution edge case scenario client continually asking server what's new fail due timestamps.

in example, i'm not using sequence numbers because of edge case problem. can see problem here: a client walks server , asks "what's new?" – problems sequence numbers

assume we're using timestamps. every row update adds timestamp of server time. clients continually ask what's new since timestamp of last item received. simple? yes, but...

failure scenario:

the times below arbitrary readability. assume milliseconds in real world.

2:50 client c checks updates. 2:59 client starts update on row. (sets lastmodified 2:59) 2:59 client b starts update on row. (sets lastmodified 2:59) 3:00 client row update becomes visible on db. (lastmodified still @ 2:59) 3:00 client c checks updates >2:50. get’s a’s update.  good. 3:01 client b row update becomes visible on db. (lastmodified still @ 2:59) 3:10 client c checks updates >2:59. gets nothing. misses b's update. bad. 

this assumes lastmodified can't set atomically , there may delay between it's setting , row becoming available in database. if database sharded, delay larger.

we set check update arbitrarily ask time causing overlap. inefficient due potentially duplicate data being retrieved not fatal. however, possible know how overlap needed cases? sharded database delay displaying update seconds? minutes?

having clients ask "what's new" repeatedly seems common use case , find surprising not find better wealth of best practices on this.

any ideas on solving scenario or recommending better, preferably platform agnostic, solution asking changes?


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -