steemit / hivemind

Developer-friendly microservice powering social networks on the Steem blockchain.
MIT License
73 stars 65 forks source link

posts_cache invalid data #78

Closed roadscape closed 6 years ago

roadscape commented 6 years ago

Somehow hive_posts_cache ended up with a large number of rows where id's did not match proper records. hive_posts has strict constraints so fortunately this is easy to detect; however it should never ever happen.

roadscape commented 6 years ago

These should always return 0:

SELECT count(*)
  FROM hive_posts hp
  JOIN hive_posts_cache hpc ON post_id = id
 WHERE hp.author != hpc.author
SELECT count(*)
  FROM hive_posts hp
  JOIN hive_posts_cache hpc ON post_id = id
 WHERE hp.permlink != hpc.permlink
roadscape commented 6 years ago

Changes:

  1. never rely on hpc for id map: https://github.com/steemit/hivemind/commit/0153e8c61cf635ed99dec334c8a152cd44ac8e06#diff-edb401a6f9d72cecf7670d6d5d054e8fR145
  2. paranoid checks on

Most likely the cause was a bug during rewrites/testing late last week. The extra assertions haven't been tripped so whatever the issue was seems to have been a temporary one. Leaving them in place for the time being.