Database changes and the role of Feed

+2 votes
I tried to change and delete some data from the database records that is already filled with the data from the feed adapter on a specific stream and also I shutdown the database server and I published an item on that stream and when I started again the DB, The changed records still changed and not synced with multichain data and also the published item on the stream didn't feed to the database. After checking the feed to restart as a solution for syncying,  I found that the feed is not running. Starting the feed again and checking the database, I found that:

- the changed data still exist and a new record of the original data has been added.

- The published item exist.
Expected:

-The changed data in the database is updated with multichain data in case of changing the data in the database .(Not adding a new record with the original data)

-The status of feed still running .
asked Apr 12, 2020 by mina

1 Answer

+1 vote
Are you using the MultiChain Feed Adapter that we distribute and have you made any changes to its code? Please also let us know which database you are using, and which changes you made to that database.

In general you should not be changing the data in the database fed from a MultiChain feed because the whole point is for that database to be a read-only replicate of the data in the chain.
answered Apr 12, 2020 by MultiChain
yes, I am using the Multichain Feed Adapter and I didn't make any changes to the code.
I am using MongoDB and I just changed the key. It is good to make the data replicated but the point is : I want to make sure that the data "within the database" is consistence even in case of any changes for any reason(like the data "Stream Item" that published on blockchain that can't be changed )
Which key do you mean?
The key of the stream item as per below the field keys contains the item key so I changed it from key1 to key_changed

{   "_id":"ObjectId("   "5e9425a691a95891d102dca1"   ")",
   "id":"755f9baa0d0373e00afa24fdc58e99db00000000",
   "binary_data":"68656c6c6f20776f726c6432",
   "dataref":"0c00000000312008d543ec67a6627602e06a75f0086847085d4843394cbec85acd41137cce010000",
   "flags":1,
   "format":"binary",
   "keys":[
      "key1"
   
],
   "publishers":[
      "18SyvhvgaeCL5aY1zFnqG9x1Zh2QE77bxzXjnb"
   
],
   "size":12,
   "txid":"755f9baa0d0373e00afa24fdc58e99db12e9d2905d7e58c7650ca63c4b40fb70",
   "vout":0,
   "blockhash":"00312008d543ec67a6627602e06a75f0086847085d4843394cbec85acd41137c",
   "blockheight":96,
   "blockpos":462,
   "confirmed":1586700667
}

Also I noted that deleting any document of the collection will be retrieved only if I make updatefeed "feed1" "*" "*" rescan, Is there any other way (configuration) to make automated syncing (once the DB changed, the feed will update it )?.
No, MultiChain feeds do not monitor what happens in the replica database, and this would introduce a great deal of complexity that is beyond the purpose of feeds. There should be no reason for you to change this database yourself, because it is meant to be a replica of the data in the chain.
Being Multichain feed not monitoring for what happens in the replica database, Is this mean that I can't guarantee consistency of data in the database to be as the data in the multichain?

My use case is making advanced and complex queries on the database and I want to be sure that data is consistence
You can guarantee it so long as you don't change the data in the database. This is similar to any other replication scenario.
we are facing the same problem ... our clients should be sure that the replicated data from the Multichan to the mongo DB are 100% consistent, there is a scenario coming up if the product builder can make some changes to the mongo DB layer before coming up with the query results.

At the end of the day, we need something that makes us sure that both Multichain layer and mongo DB layer are identical as long as we are dealing with assets management and critical data ... the user should trust the system that no one (from inside the company that developed the product) has the authority to make any changes at the mondo DB layer before showing up the query results.
Can you manage this with regular database permissions, so that the MongoDB password is set after the solution is built and handed over, and then this password is set in the feed adapter configuration? You can also ensure that no other users can modify the MongoDB database except this adapter itself.
this is a great solution to manage the process internally, but the user should see this process as one of the Blockchain consonances rules in the system ... I am not talking from the company internal process perspective ... for me as a user, how can I trust in this particular solution as long as there is a percentage (even if it is small) for someone to have a certain kind of controlling over the replicated data.
With feeds each user can run their own replica database from their own node, and query that replica directly, so they only have to trust themselves. No matter what we did in MultiChain there is no way to guarantee that someone else's replica has not been tampered with, because that other person could always stop MultiChain running, and then tamper with the database after that. It's just not possible.
...