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

funk locking fixes #3908

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/flamenco/runtime/fd_acc_mgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -314,11 +314,10 @@ fd_acc_mgr_save_non_tpool( fd_acc_mgr_t * acc_mgr,
fd_funk_rec_key_t key = fd_acc_funk_key( account->pubkey );
fd_funk_t * funk = acc_mgr->funk;
fd_funk_rec_t * rec = (fd_funk_rec_t *)fd_funk_rec_query( funk, txn, &key );
Copy link
Member

Choose a reason for hiding this comment

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

looks like this needs a read lock

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I thought funk allows lock-free read operations. How do I get a read lock for funk?

fd_funk_start_write( acc_mgr->funk );
if( rec == NULL ) {
int err;
fd_funk_start_write( acc_mgr->funk );
rec = (fd_funk_rec_t *)fd_funk_rec_insert( funk, txn, &key, &err );
fd_funk_end_write( acc_mgr->funk );
if( rec == NULL ) FD_LOG_ERR(( "unable to insert a new record, error %d", err ));
}
account->rec = rec;
Expand All @@ -330,6 +329,7 @@ fd_acc_mgr_save_non_tpool( fd_acc_mgr_t * acc_mgr,
if( fd_funk_val_truncate( account->rec, reclen, fd_funk_alloc( acc_mgr->funk, wksp ), wksp, &err ) == NULL ) {
FD_LOG_ERR(( "unable to allocate account value, err %d", err ));
}
fd_funk_end_write( acc_mgr->funk );
Copy link
Member

Choose a reason for hiding this comment

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

not sure i'm a fan calling LOG_ERR while holding the lock ... funk is now invalid which is an issue for persistent funk

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There are tons of cases where we FD_LOG_ERR, while holding a funk lock: fd_runtime_process_genesis_block, fd_migrate_builtin_to_core_bpf, fd_runtime_collect_rent_accounts_prune, and many more. Getting rid of this would be a bigger change, or potentially something we want to do atexit.

return fd_acc_mgr_save( acc_mgr, account );
}

Expand Down
4 changes: 3 additions & 1 deletion src/flamenco/runtime/tests/fd_exec_instr_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -727,8 +727,10 @@ _txn_context_create_and_exec( fd_exec_instr_test_runner_t * runner,
( rent->exemption_threshold < 0.0 ) |
( rent->exemption_threshold > 999.0 ) |
( rent->lamports_per_uint8_year > UINT_MAX ) |
( rent->burn_percent > 100 ) )
( rent->burn_percent > 100 ) ) {
fd_funk_end_write( runner->funk );
return NULL;
}

/* Blockhash queue is given in txn message. We need to populate the following three:
- slot_ctx->slot_bank.block_hash_queue (TODO: Does more than just the last_hash need to be populated?)
Expand Down
Loading