Skip to content

Commit

Permalink
Fixed Bug with infinite loop on init
Browse files Browse the repository at this point in the history
  • Loading branch information
amigin committed Jun 20, 2022
1 parent f7f4455 commit 5bf3a60
Show file tree
Hide file tree
Showing 15 changed files with 42 additions and 11 deletions.
4 changes: 3 additions & 1 deletion JavaScript/HtmlMain.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion JavaScript/HtmlMain.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion JavaScript/main.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@
* Added settings parameter

### 0.0.20-rc01
* Sync to Readers now works in separated thread
* Sync to Readers now works in a separate thread
* Exposed sync to readers bytes to Prometheus reader by reader
4 changes: 3 additions & 1 deletion TypeScript/HtmlMain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ class HtmlMain {

public static generateInit(model: INonInitializedModel): string {

var result = '<h1>Remains tables to load: ' + model.tablesRemains + '</h1><h2>Total loading time is: ' + this.formatSeconds(model.initializingSeconds) + '</h2>' +
var result = '<h1>Remains tables to load: ' + model.tablesRemains + '</h1>' +
'<h2>Table which files are being loaded: ' + model.tableBeingLoadedFiles + '</h2>' +
'<h2>Total loading time is: ' + this.formatSeconds(model.initializingSeconds) + '</h2>' +
'<table class="table table-striped table-bordered"><tr><th>TableName</th><th>Partitions loaded</th><th>Partitions total</th><th>Time gone</th><th>Time estimation</th></tr>'

for (let itm of model.progress.sort((a, b) => a.tableName > b.tableName ? 1 : -1)) {
Expand Down
1 change: 1 addition & 0 deletions TypeScript/contracts.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ interface INonInitializedModel {
tablesRemains: number,
initializingSeconds: number,
progress: ITableLoadProgress[]
tableBeingLoadedFiles: String
}


Expand Down
2 changes: 0 additions & 2 deletions TypeScript/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ class main {
this.layoutElement.innerHTML = HtmlMain.generateInit(result.notInitialized);
}



HtmlStatusBar.updateStatusbar(result.statusBar);

}).fail(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ pub struct NonInitializedModel {
#[serde(rename = "initializingSeconds")]
initializing_seconds: i64,
progress: Vec<TableProgressModel>,
#[serde(rename = "tableBeingLoadedFiles")]
table_being_loaded_files: Option<String>,
}

impl NonInitializedModel {
Expand All @@ -30,6 +32,7 @@ impl NonInitializedModel {
progress,
tables_remains: snapshot.to_load.len(),
initializing_seconds: now.seconds_before(app.created),
table_being_loaded_files: snapshot.table_being_loaded_files,
};
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ async fn load_table_files_loop(
.await;
}
PartitionToLoad::EndOfReading => {
break;
return;
}
},
None => {
Expand Down
3 changes: 2 additions & 1 deletion src/persist_operations/data_initializer/load_tables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ async fn load_tables_spawned(app: Arc<AppContext>) {
);
}
super::load_tasks::ProcessTableToLoad::NotReadyYet => {
tokio::time::sleep(Duration::from_millis(100)).await;
println!("We do not have table to load yet");
tokio::time::sleep(Duration::from_millis(1000)).await;
}
super::load_tasks::ProcessTableToLoad::TheEnd => {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ impl InitState {
write_access.get_next_table_to_init_files()
}

pub async fn loading_files_for_tables_is_done(&self) {
let mut write_access = self.data.lock().await;
write_access.loading_files_for_tables_is_done();
}

pub async fn get_next_table_to_load(&self) -> ProcessTableToLoad {
let mut write_access = self.data.lock().await;
write_access.get_next_table_to_load()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ pub enum ProcessTableToLoad {
}

pub struct InitStateData {
pub table_being_loaded_files: Option<String>,
pub tables_to_init_files: Vec<Arc<TableToLoad>>,
pub tables_to_load: Vec<ProcessTableToLoad>,
pub tables_being_loaded: Vec<Arc<TableToLoad>>,
Expand All @@ -24,6 +25,7 @@ impl InitStateData {
tables_to_load: Vec::new(),
tables_being_loaded: Vec::new(),
tables_loaded: Vec::new(),
table_being_loaded_files: None,
}
}

Expand All @@ -34,13 +36,18 @@ impl InitStateData {
}

let result = self.tables_to_init_files.remove(0);
self.table_being_loaded_files = Some(result.table_name.to_string());

self.tables_to_load
.push(ProcessTableToLoad::Process(result.clone()));

Some(result)
}

pub fn loading_files_for_tables_is_done(&mut self) {
self.table_being_loaded_files = None;
}

pub fn init_tables(&mut self, tables: Vec<String>, logs: &Logs) {
for table_name in tables {
if let Err(err) = validation::validate_table_name(table_name.as_str()) {
Expand All @@ -66,7 +73,14 @@ impl InitStateData {
if self.tables_to_load.len() > 0 {
self.tables_to_load.remove(0)
} else {
ProcessTableToLoad::NotReadyYet
if self.tables_being_loaded.len() == 0
&& self.tables_to_load.len() == 0
&& self.tables_to_init_files.len() == 0
{
ProcessTableToLoad::TheEnd
} else {
ProcessTableToLoad::NotReadyYet
}
}
};

Expand Down Expand Up @@ -101,6 +115,7 @@ impl InitStateData {
to_load: convert_to_tables_snapshot_2(&self.tables_to_load),
loading: convert_to_tables_snapshot(&self.tables_being_loaded),
loaded: convert_to_tables_snapshot(&self.tables_loaded),
table_being_loaded_files: self.table_being_loaded_files.clone(),
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ pub struct InitStateSnapshot {
pub to_load: Vec<InitTableStateSnapshot>,
pub loading: Vec<InitTableStateSnapshot>,
pub loaded: Vec<InitTableStateSnapshot>,
pub table_being_loaded_files: Option<String>,
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ pub async fn table_list_of_files_loader(app: Arc<AppContext>) {
while let Some(table_to_load) = app.init_state.get_next_table_to_init_files().await {
app.persist_io.get_table_files(&table_to_load).await;
}

app.init_state.loading_files_for_tables_is_done().await;
}
Loading

0 comments on commit 5bf3a60

Please sign in to comment.