Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Anusha-Padmanabhan
Copy link
Contributor

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?

NONE

Additional documentation, usage docs, etc.:


Signed-off-by: Anusha <anu.vp.nair@gmail.com>
Comment on lines +429 to +435
case purge_mode[0]: {
response = await this.persistence.
getCrudService().
deleteOldData(channel_genesis_hash, network_id, daysToPurge);
break;
}
case purge_mode[1]: {
Copy link
Contributor

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]

Comment on lines +22 to +24
export enum PurgeModes {
'TIME',
'BLOCKCOUNT'
Copy link
Contributor

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",
Copy link
Contributor

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).

Copy link
Contributor

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',
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Purging old records from explorer database
3 participants