@@ -785,7 +785,7 @@ OLAPTablePtr OLAPEngine::_get_table_with_no_lock(TTabletId tablet_id, SchemaHash
785785 return olap_table;
786786}
787787
788- OLAPTablePtr OLAPEngine::get_table (TTabletId tablet_id, SchemaHash schema_hash, bool load_table) {
788+ OLAPTablePtr OLAPEngine::get_table (TTabletId tablet_id, SchemaHash schema_hash, bool load_table, std::string* err ) {
789789 _tablet_map_lock.rdlock ();
790790 OLAPTablePtr olap_table;
791791 olap_table = _get_table_with_no_lock (tablet_id, schema_hash);
@@ -794,13 +794,18 @@ OLAPTablePtr OLAPEngine::get_table(TTabletId tablet_id, SchemaHash schema_hash,
794794 if (olap_table.get () != NULL ) {
795795 if (!olap_table->is_used ()) {
796796 OLAP_LOG_WARNING (" olap table cannot be used. [table=%ld]" , tablet_id);
797+ if (err != nullptr ) { *err = " tablet cannot be used" ; }
797798 olap_table.reset ();
798799 } else if (load_table && !olap_table->is_loaded ()) {
799- if (olap_table->load () != OLAP_SUCCESS) {
800+ OLAPStatus ost = olap_table->load ();
801+ if (ost != OLAP_SUCCESS) {
800802 OLAP_LOG_WARNING (" fail to load olap table. [table=%ld]" , tablet_id);
803+ if (err != nullptr ) { *err = " load tablet failed" ; }
801804 olap_table.reset ();
802805 }
803806 }
807+ } else if (err != nullptr ) {
808+ *err = " tablet does not exist" ;
804809 }
805810
806811 return olap_table;
@@ -835,6 +840,10 @@ OLAPStatus OLAPEngine::get_tables_by_id(
835840 it = table_list->erase (it);
836841 continue ;
837842 }
843+ } else if ((*it)->is_used ()) {
844+ LOG (WARNING) << " table is bad: " << (*it)->full_name ().c_str ();
845+ it = table_list->erase (it);
846+ continue ;
838847 }
839848 ++it;
840849 }
@@ -1884,7 +1893,7 @@ OLAPTablePtr OLAPEngine::_find_best_tablet_to_compaction(CompactionType compacti
18841893 OLAPTablePtr best_table;
18851894 for (tablet_map_t ::value_type& table_ins : _tablet_map){
18861895 for (OLAPTablePtr& table_ptr : table_ins.second .table_arr ) {
1887- if (!table_ptr->is_loaded () || !_can_do_compaction (table_ptr)) {
1896+ if (!table_ptr->is_used () || !table_ptr-> is_loaded () || !_can_do_compaction (table_ptr)) {
18881897 continue ;
18891898 }
18901899
0 commit comments