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

[Bug] drop table column fail #1795

Closed
Kree0 opened this issue Nov 24, 2023 · 2 comments
Closed

[Bug] drop table column fail #1795

Kree0 opened this issue Nov 24, 2023 · 2 comments
Assignees

Comments

@Kree0
Copy link
Contributor

Kree0 commented Nov 24, 2023

Describe the bug

Version: cnosdb 2.3.4, revision 508f669
Mode: singleton | 3meta+2tskv

public ❯ create table t1(a bigint, b bigint);
Query took 0.006 seconds.
public ❯ ALTER TABLE t1 drop b;
422 Unprocessable Entity, details: {"error_code":"050014","error_message":"Unreachable"}

Stack backtrace:
   0: anyhow::error::<impl anyhow::Error>::msg
   1: anyhow::__private::format_err
   2: client::ctx::SessionContext::sql::{{closure}}
   3: client::exec::exec_and_print::{{closure}}
   4: client::exec::exec_from_repl::{{closure}}
   5: cnosdb_cli::main::{{closure}}
   6: cnosdb_cli::main
   7: std::sys_common::backtrace::__rust_begin_short_backtrace
   8: std::rt::lang_start::{{closure}}
   9: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once
             at ./rustc/39f2657d1101b50f9b71ae460b762d330cc8426b/library/core/src/ops/function.rs:287:13
  10: std::panicking::try::do_call
             at ./rustc/39f2657d1101b50f9b71ae460b762d330cc8426b/library/std/src/panicking.rs:487:40
  11: std::panicking::try
             at ./rustc/39f2657d1101b50f9b71ae460b762d330cc8426b/library/std/src/panicking.rs:451:19
  12: std::panic::catch_unwind
             at ./rustc/39f2657d1101b50f9b71ae460b762d330cc8426b/library/std/src/panic.rs:140:14
  13: std::rt::lang_start_internal::{{closure}}
             at ./rustc/39f2657d1101b50f9b71ae460b762d330cc8426b/library/std/src/rt.rs:148:48
  14: std::panicking::try::do_call
             at ./rustc/39f2657d1101b50f9b71ae460b762d330cc8426b/library/std/src/panicking.rs:487:40
  15: std::panicking::try
             at ./rustc/39f2657d1101b50f9b71ae460b762d330cc8426b/library/std/src/panicking.rs:451:19
  16: std::panic::catch_unwind
             at ./rustc/39f2657d1101b50f9b71ae460b762d330cc8426b/library/std/src/panic.rs:140:14
  17: std::rt::lang_start_internal
             at ./rustc/39f2657d1101b50f9b71ae460b762d330cc8426b/library/std/src/rt.rs:148:20
  18: main
  19: <unknown>
  20: __libc_start_main
  21: _start

To Reproduce

No response

Expected behavior

No response

Additional context

No response

@zipper-meng
Copy link
Member

There is a bug that database in TsKv: Engine can be detected only after we wrote something to it:

cnosdb/tskv/src/kvcore.rs

Lines 959 to 986 in 6765f19

async fn drop_table_column(
&self,
tenant: &str,
database: &str,
table: &str,
column_name: &str,
) -> Result<()> {
// TODO(zipper): Store this action in WAL.
let db = self.get_db(tenant, database).await?;
let schema =
db.read()
.await
.get_table_schema(table)?
.ok_or_else(|| SchemaError::TableNotFound {
database: database.to_string(),
table: table.to_string(),
})?;
let column_id = schema
.column(column_name)
.ok_or_else(|| SchemaError::FieldNotFound {
database: database.to_string(),
table: table.to_string(),
field: column_name.to_string(),
})?
.id;
self.delete_columns(db, table, &[column_id]).await?;
Ok(())
}

Line 967 self.get_db() returned Err(DatabaseNotFound), then upstream printed the log and returned Unreachable to user.

@Kree0 Kree0 changed the title [Bug] drop table column fail in k8s [Bug] drop table column fail Jan 15, 2024
lutengda added a commit to lutengda/cnosdb that referenced this issue Jan 22, 2024
@lutengda lutengda assigned Kree0 and unassigned lutengda Jan 22, 2024
@Kree0
Copy link
Contributor Author

Kree0 commented May 11, 2024

It's solved in cnosdb 2.4.1, revision cc1af6a

public ❯ create table t1(a bigint, b bigint);
Query took 0.027 seconds.
public ❯ ALTER TABLE t1 drop b;
Query took 0.029 seconds.

@Kree0 Kree0 closed this as completed May 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants