Skip to content

Fixed orphaned nodes blocking resume & nil pointer crash#327

Open
Pranav-1100 wants to merge 2 commits intostoracha:mainfrom
Pranav-1100:orphaned-nodes
Open

Fixed orphaned nodes blocking resume & nil pointer crash#327
Pranav-1100 wants to merge 2 commits intostoracha:mainfrom
Pranav-1100:orphaned-nodes

Conversation

@Pranav-1100
Copy link
Contributor

This fixes issue #258 where uploads couldn't resume if a node was left orphaned (created in the DB but not linked to the upload) after a crash.

I initially tried to fix this by adding a DeleteNode rollback, but after testing I realized that wouldn't work for hard crashes (like power loss) where the cleanup code never runs.
So instead, I changed the logic to check completion using the node_uploads table rather than just the nodes table. Now, if a node exists in the database but isn’t linked to the current upload, we treat it as incomplete and attempt to link it again. I also updated the SQL insert query so that these cases don’t cause duplicate errors.

Additionally, I fixed a segmentation fault in ReadNodeFromDatabase by checking whether path and offset pointers are nil before dereferencing them. This prevents crashes when reading nodes with null values.

To verified this:-
I created a local test case that simulates an orphaned UnixFS node valid in the DB but missing from node_uploads.

Before the fix: The test failed because the system assumed the node was already done and skipped linking it.
After the fix: The test passed the system correctly detected the missing link and recovered the node.

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.

1 participant