Skip to content

Commit

Permalink
[#24012] YSQL: Replace deprecated function shared_ptr::unique to fix …
Browse files Browse the repository at this point in the history
…macos compiler error

Summary:
An unknown change started causing compilation errors on macos. Fix these compiler errors.

Error 1: deprecated function error

```
/-------------------------------------------------------------------------------
| COMPILATION FAILED
|-------------------------------------------------------------------------------
../../src/yb/util/debug/long_operation_tracker.cc:119:22: error: no member named 'unique' in 'std::shared_ptr<yb::LongOperationTracker::TrackedOperation>'
  119 |       if (!operation.unique()) {
      |            ~~~~~~~~~ ^
../../src/yb/util/debug/long_operation_tracker.cc:124:24: error: no member named 'unique' in 'std::shared_ptr<yb::LongOperationTracker::TrackedOperation>'
  124 |         if (!operation.unique()) {
      |              ~~~~~~~~~ ^
2 errors generated.

Input files:
  src/yb/util/CMakeFiles/yb_util.dir/debug/long_operation_tracker.cc.o
  /Users/tfoucher/code/yugabyte-db3/src/yb/util/debug/long_operation_tracker.cc
Output file (from -o): src/yb/util/CMakeFiles/yb_util.dir/debug/long_operation_tracker.cc.o
\-------------------------------------------------------------------------------
```

Error2: unused variable error

```
/-------------------------------------------------------------------------------
| COMPILATION FAILED
|-------------------------------------------------------------------------------
../../src/yb/docdb/docdb_util.cc:46:19: error: unused variable 'kEmptyLogPrefix' [-Werror,-Wunused-const-variable]
   46 | const std::string kEmptyLogPrefix;
      |                   ^~~~~~~~~~~~~~~
1 error generated.

Input files:
  src/yb/docdb/CMakeFiles/yb_docdb.dir/docdb_util.cc.o
  /Users/pbalivada/code/xcode/src/yb/docdb/docdb_util.cc
Output file (from -o): src/yb/docdb/CMakeFiles/yb_docdb.dir/docdb_util.cc.o
\-------------------------------------------------------------------------------
```

Error 3: unused variable error

```
/-------------------------------------------------------------------------------
| COMPILATION FAILED
|-------------------------------------------------------------------------------
../../src/yb/util/metrics-test.cc:64:21: error: unused variable 'kTableId' [-Werror,-Wunused-const-variable]
   64 | static const string kTableId = "table_id";
      |                     ^~~~~~~~
1 error generated.

Input files:
  src/yb/util/CMakeFiles/metrics-test.dir/metrics-test.cc.o
  /Users/pbalivada/code/xcode/src/yb/util/metrics-test.cc
Output file (from -o): src/yb/util/CMakeFiles/metrics-test.dir/metrics-test.cc.o
\-------------------------------------------------------------------------------
```

Fixes #24012
Jira: DB-12899

Test Plan: Jenkins

Reviewers: hsunder

Reviewed By: hsunder

Subscribers: hsunder, ybase

Differential Revision: https://phorge.dev.yugabyte.com/D38164
  • Loading branch information
pao214 committed Sep 18, 2024
1 parent 28d0d8e commit 9feb6e8
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 10 deletions.
6 changes: 0 additions & 6 deletions src/yb/docdb/docdb_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,6 @@ namespace docdb {

using dockv::DocPath;

namespace {

const std::string kEmptyLogPrefix;

}

Status SetValueFromQLBinaryWrapper(
QLValuePB ql_value, const int pg_data_type,
const std::unordered_map<uint32_t, string>& enum_oid_label_map,
Expand Down
4 changes: 2 additions & 2 deletions src/yb/util/debug/long_operation_tracker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,12 @@ class LongOperationTrackerHelper {

TrackedOperationPtr operation = queue_.top();
queue_.pop();
if (!operation.unique()) {
if (operation.use_count() > 1) {
lock.unlock();
auto stack = DumpThreadStack(operation->thread_id);
// Make sure the task did not complete while we were dumping the stack. Else we could get
// some other innocent stack.
if (!operation.unique()) {
if (operation.use_count() > 1) {
LOG(WARNING) << operation->message << " running for " << MonoDelta(now - operation->start)
<< " in thread " << operation->thread_id << ":\n"
<< stack;
Expand Down
2 changes: 0 additions & 2 deletions src/yb/util/metrics-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ namespace yb {

METRIC_DEFINE_entity(test_entity);

static const string kTableId = "table_id";

class MetricsTest : public YBTest {
public:
void SetUp() override {
Expand Down

0 comments on commit 9feb6e8

Please sign in to comment.