Skip to content

Commit

Permalink
Fix race between data sync and data load
Browse files Browse the repository at this point in the history
Be sure we trigger the startup cluster sync AFTER loading the data from DB.
Also, when receiving replicated data, be sure the data is actually loaded.
Closes #2581
  • Loading branch information
bogdan-iancu committed Aug 11, 2021
1 parent ac6f3a2 commit 3b8bdb7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
7 changes: 2 additions & 5 deletions modules/drouting/dr_clustering.c
Expand Up @@ -160,7 +160,7 @@ static int gw_status_update(bin_packet_t *packet, int raise_event)
bin_pop_int(packet, &flags);

part = get_partition( &part_name );
if (part==NULL)
if (part==NULL || part->rdata==NULL)
return -1;

lock_start_read(part->ref_lock);
Expand Down Expand Up @@ -197,7 +197,7 @@ static int cr_status_update(bin_packet_t *packet)
bin_pop_int(packet, &flags);

part = get_partition( &part_name );
if (part==NULL)
if (part==NULL || part->rdata==NULL)
return -1;

lock_start_read(part->ref_lock);
Expand Down Expand Up @@ -377,8 +377,5 @@ int dr_init_cluster(void)
dr_cluster_shtag.len = 0;
}

if (dr_cluster_sync() < 0)
return -1;

return 0;
}
3 changes: 3 additions & 0 deletions modules/drouting/drouting.c
Expand Up @@ -1930,6 +1930,9 @@ static int db_connect_head(struct head_db *x) {
static void rpc_dr_reload_data(int sender_id, void *unused)
{
dr_reload_data(1);

dr_cluster_sync();

}


Expand Down

0 comments on commit 3b8bdb7

Please sign in to comment.