-
Notifications
You must be signed in to change notification settings - Fork 949
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
purge functionality based on blockcount and time #362
base: main
Are you sure you want to change the base?
purge functionality based on blockcount and time #362
Conversation
Signed-off-by: Anusha <anu.vp.nair@gmail.com>
case purge_mode[0]: { | ||
response = await this.persistence. | ||
getCrudService(). | ||
deleteOldData(channel_genesis_hash, network_id, daysToPurge); | ||
break; | ||
} | ||
case purge_mode[1]: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you check if we can use the enums here instead of purge_mode[0] and purge_mode[1]
export enum PurgeModes { | ||
'TIME', | ||
'BLOCKCOUNT' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about having the Enums like this
PurgeModes {
TIME = "TIME"
}
"profile": "./connection-profile/test-network.json" | ||
"profile": "./connection-profile/test-network.json", | ||
"blockCount": 5, | ||
"purgeMode":"NONE", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume we will now have the following purgemode NONE, TIME,BLOCKCOUNT, are we also handling the NONE case as well (which means no purge is needed).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, we are handling the NONE case(* No purge) too.
@@ -18,3 +18,8 @@ export const fabric = { | |||
NOTITY_TYPE_CLIENTERROR: '6' | |||
} | |||
}; | |||
|
|||
export enum PurgeModes { | |||
'TIME', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we have the NONE as purge mode, then we need to handle that case, can you check this case once.
What this PR does / why we need it:
Now explorer database is saving each transaction that is committed on to the ledger making replica copies of ledger. When number of transactions increases there is a chance of outage of postgres database. In order to address this we would keep only the recent data in database and provide a query back mechanism to read back from the blockchain for any of the purged data.
Implementation
Based on BLOCKCOUNT
Based on TIME
We can set the purgeMode attribute in config.json file and according to the purge mode, it enables purging from database.
If it is based on blockcount (mention the number of blocks as blockCount value in config.json) ,it will retain those many blocks in the database and the rest of the records would be purged.
If it is based on time (mention the number of days as daysToPurge value in config.json) then it will keep those many days of records in the database according to the daystoPurge provided in the config file.
If the purgeMode attribute is set to "NONE", then purging won't happen and it will retain the complete data as of ledger.
All the audit records of deletion is saved to explorer_audit_table which is further used for the sync process.
Why is this needed?
Explorer creates duplicate copy of complete ledger data in postgres which can be of larger number and can lead to database storage outage.
Which issue(s) this PR fixes:
Fixes #332
Special notes for your reviewer:
Does this PR introduce a user-facing change?
Additional documentation, usage docs, etc.: