Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Rewrite all database logic to follow pg-promise best practices #213

Closed
fix opened this issue Jun 21, 2016 · 3 comments
Closed

Rewrite all database logic to follow pg-promise best practices #213

fix opened this issue Jun 21, 2016 · 3 comments

Comments

@fix
Copy link
Contributor

fix commented Jun 21, 2016

under modules/block.js
This way we can throw an error an prevent from rewinding already applied transactions.

Edited by @karmacoma.

If a node is interrupted during block processing i.e. due to reload, there is a high probability of partial writes to the database, leading to corruption of memory tables and a break in consensus with the rest of network.

Solution: Rewrite database logic so that block save, block application, and round tick are all encompassed within an atomic database transaction that can be easily rolled back upon interruption or error.

This should better ensure data integrity across nodes on the network.

@karmacoma karmacoma added this to the Version 0.3.2 milestone Jun 21, 2016
@karmacoma karmacoma added the ready label Jul 1, 2016
@karmacoma karmacoma removed the ready label Aug 19, 2016
@karmacoma karmacoma modified the milestone: Mainchain Stabilisation Aug 31, 2016
@karmacoma karmacoma added the ready label Sep 6, 2016
@karmacoma karmacoma changed the title Wrap applyBlock into a database tx Prevent data corruption on node shutdown during block processing Sep 18, 2016
karmacoma pushed a commit that referenced this issue Sep 18, 2016
When shutting down node during block processing.

- Tracking cleanup status through __private.cleanup.
- Skipping blocks on cleanup for Blocks.prototype.loadBlocksOffset.
- Skipping blocks on cleanup for Blocks.prototype.loadBlocksFromPeer.
- Exiting Blocks.prototype.processBlock early on cleanup.
@karmacoma
Copy link
Contributor

Above commit, is not a complete solution. Next step is to ensure block, transactions and memory table writes are all within atomic db transaction(s).

@karmacoma karmacoma added the hard label Sep 30, 2016
@karmacoma karmacoma changed the title Prevent data corruption on node shutdown during block processing Rewrite all database logic to follow pg-promise best practices Oct 29, 2016
@karmacoma
Copy link
Contributor

Shifting this issue up a gear. Logic rewrite will provide better use of shared connections from pool and make block processing fully atomic as originally intended.

@karmacoma
Copy link
Contributor

Closing and moving to here: #302

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

No branches or pull requests

2 participants