Skip to content

fix: add missing is_latest filter to network account query#1578

Merged
bobbinth merged 2 commits intonextfrom
santiagopittella-fix-network-account-query
Jan 22, 2026
Merged

fix: add missing is_latest filter to network account query#1578
bobbinth merged 2 commits intonextfrom
santiagopittella-fix-network-account-query

Conversation

@SantiagoPittella
Copy link
Collaborator

Fixes ntx-builder crash on node restart after a network transaction has been processed. After a network transaction updates a network account, restarting the node causes the ntx-builder to fail with:

ERROR account actor already exists for account: 0x...
Error: Component ntx-builder failed
Caused by: event channel closed

The select_all_network_account_ids query was missing an is_latest = true filter. Without filtering for is_latest, both historical and current rows were returned, causing duplicate account IDs to be sent to the ntx-builder, which then attempted to spawn multiple actors for the same account.

Added .filter(schema::accounts::is_latest.eq(true)) to ensure only the current state of each account is returned. I saw that this filter was removed in #1481 so I want to confirm with @drahnr if we should fix it in another way.

@SantiagoPittella SantiagoPittella added the store Related to the store component label Jan 22, 2026
Copy link
Contributor

@bobbinth bobbinth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thank you! I left one comment inline to be tackled in a separate PR.

QueryDsl::select(
schema::accounts::table
.filter(schema::accounts::network_account_id_prefix.is_not_null()),
.filter(schema::accounts::network_account_id_prefix.is_not_null())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not for this PR, but we should probably replace network_account_id_prefix with something like network_account_type.

@Mirko-von-Leipzig
Copy link
Collaborator

I'll check tomorrow, but the ntx does need to handle duplicate accounts in its event loop. This is because it's possible for the account info to arrive from the store and also as part of the mempool event.

However the store should only be sending unique network accounts.

@bobbinth
Copy link
Contributor

I'll check tomorrow, but the ntx does need to handle duplicate accounts in its event loop. This is because it's possible for the account info to arrive from the store and also as part of the mempool event.

However the store should only be sending unique network accounts.

I think we should merge this regardless as it fixes the store-side issue. We may need to follow up with improved handling on the NTX builder side though.

@SantiagoPittella
Copy link
Collaborator Author

I will continue with this two other PRs then, one for the prefix removal and another for the duplication handling

@bobbinth bobbinth merged commit 29e77b4 into next Jan 22, 2026
7 checks passed
@bobbinth bobbinth deleted the santiagopittella-fix-network-account-query branch January 22, 2026 19:03
@drahnr
Copy link
Contributor

drahnr commented Jan 22, 2026

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

store Related to the store component

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants