* concurrent scan pattern: * start n_scanners and n_writers * scanners share in-mem snapshots and writers use copies of storage_t */
| 755 | * scanners share in-mem snapshots and writers use copies of storage_t |
| 756 | */ |
| 757 | void e2e_concurrent_scan_pattern(int n_checkpoints, int n_scanners, int n_writers, |
| 758 | fdb_config fconfig, bool walflush) |
| 759 | { |
| 760 | |
| 761 | int n, i; |
| 762 | storage_t **st = alca(storage_t *, n_writers); |
| 763 | storage_t **st2 = alca(storage_t *, n_writers); |
| 764 | checkpoint_t *verification_checkpoint = alca(checkpoint_t, n_writers); |
| 765 | idx_prams_t *index_params = alca(idx_prams_t, n_writers); |
| 766 | fdb_kvs_config kvs_config = fdb_get_default_kvs_config(); |
| 767 | thread_t *tid_sc = alca(thread_t, n_scanners); |
| 768 | void **thread_ret_sc = alca(void *, n_scanners); |
| 769 | thread_t *tid_wr = alca(thread_t, n_writers); |
| 770 | void **thread_ret_wr = alca(void *, n_writers); |
| 771 | fdb_kvs_handle **scan_kv = alca(fdb_kvs_handle *, n_scanners); |
| 772 | n_checkpoints = n_checkpoints * LOAD_FACTOR; |
| 773 | |
| 774 | memleak_start(); |
| 775 | |
| 776 | // init |
| 777 | rm_storage_fs(); |
| 778 | |
| 779 | |
| 780 | // init storage handles |
| 781 | for(i=0;i<n_writers;++i){ |
| 782 | gen_index_params(&index_params[i]); |
| 783 | memset(&verification_checkpoint[i], 0, sizeof(checkpoint_t)); |
| 784 | st[i] = init_storage(&fconfig, &fconfig, &kvs_config, |
| 785 | &index_params[i], &verification_checkpoint[i], walflush); |
| 786 | st2[i] = init_storage(&fconfig, &fconfig, &kvs_config, |
| 787 | &index_params[i], &verification_checkpoint[i], walflush); |
| 788 | memcpy(st2[i]->keyspace, st[i]->keyspace, KEYSPACE_LEN); |
| 789 | } |
| 790 | |
| 791 | // load init data |
| 792 | start_checkpoint(st[0]); |
| 793 | for (i=0;i<100;++i){ |
| 794 | load_persons(st[0]); |
| 795 | } |
| 796 | end_checkpoint(st[0]); |
| 797 | verify_db(st[0]); |
| 798 | |
| 799 | for (n=0;n<n_checkpoints;++n){ |
| 800 | |
| 801 | // start writer threads |
| 802 | for (i=0;i<n_writers;++i){ |
| 803 | st[i]->verify_set = false; |
| 804 | start_checkpoint(st[i]); |
| 805 | thread_create(&tid_wr[i], writer_thread, (void*)st[i]); |
| 806 | } |
| 807 | |
| 808 | // start scanner threads |
| 809 | for (i=0;i<n_scanners;++i){ |
| 810 | scan_kv[i] = scan(st2[i], NULL); |
| 811 | thread_create(&tid_sc[i], scan_thread, (void*)scan_kv[i]); |
| 812 | } |
| 813 | |
| 814 | // join scan threads |
no test coverage detected