|
16 | 16 |
|
17 | 17 | #define USING_LOG_PREFIX SERVER |
18 | 18 |
|
| 19 | +#include <unistd.h> |
19 | 20 | #include "observer/ob_server.h" |
20 | 21 | #include "lib/alloc/memory_dump.h" |
21 | 22 | #include "lib/oblog/ob_log_compressor.h" |
@@ -1757,10 +1758,22 @@ int ObServer::init_config(const ObServerOptions &opts) |
1757 | 1758 | // Create directory before opening database (handles both normal dir and symlink) |
1758 | 1759 | const char *meta_db_dir = "./store/sstable"; |
1759 | 1760 | const char *meta_db_path = "./store/sstable/meta.db"; |
1760 | | - if (OB_FAIL(FileDirectoryUtils::create_full_path(meta_db_dir))) { |
| 1761 | + |
| 1762 | + // Convert relative path to absolute path to ensure stability when working directory changes |
| 1763 | + char cwd[OB_MAX_FILE_NAME_LENGTH] = {0}; |
| 1764 | + char abs_meta_db_path[OB_MAX_FILE_NAME_LENGTH] = {0}; |
| 1765 | + if (nullptr == getcwd(cwd, sizeof(cwd))) { |
| 1766 | + ret = OB_ERR_UNEXPECTED; |
| 1767 | + LOG_ERROR("failed to get current working directory", K(ret)); |
| 1768 | + } else { |
| 1769 | + snprintf(abs_meta_db_path, sizeof(abs_meta_db_path), "%s/%s", cwd, meta_db_path); |
| 1770 | + } |
| 1771 | + |
| 1772 | + if (OB_FAIL(ret)) { |
| 1773 | + } else if (OB_FAIL(FileDirectoryUtils::create_full_path(meta_db_dir))) { |
1761 | 1774 | LOG_ERROR("failed to create meta db directory", K(ret), K(meta_db_dir)); |
1762 | | - } else if (OB_FAIL(meta_db_pool_.init(meta_db_path))) { |
1763 | | - LOG_ERROR("meta_db_pool_ init failed", K_(self_addr), KR(ret), K(meta_db_path)); |
| 1775 | + } else if (OB_FAIL(meta_db_pool_.init(abs_meta_db_path))) { |
| 1776 | + LOG_ERROR("meta_db_pool_ init failed", K_(self_addr), KR(ret), K(abs_meta_db_path)); |
1764 | 1777 | } else if (OB_FAIL(config_mgr_.init(&meta_db_pool_))) { |
1765 | 1778 | LOG_ERROR("config_mgr_ init failed", K_(self_addr), KR(ret)); |
1766 | 1779 | } else if (OB_FAIL(config_mgr_.got_version())) { |
|
0 commit comments