Zoltan Borok-Nagy has posted comments on this change. ( 
http://gerrit.cloudera.org:8080/24416 )

Change subject: IMPALA-15079: Cleanup Open/Close locking in SharedJdbcConnection
......................................................................


Patch Set 1:

(2 comments)

http://gerrit.cloudera.org:8080/#/c/24416/1/be/src/exec/data-source-scan-node.cc
File be/src/exec/data-source-scan-node.cc:

http://gerrit.cloudera.org:8080/#/c/24416/1/be/src/exec/data-source-scan-node.cc@126
PS1, Line 126: notify_all
Since threads are contending for std::mutex, notify_one() could be called 
instead, since there will be exactly one winner anyway. Also, it should be 
called outside of the lock.


http://gerrit.cloudera.org:8080/#/c/24416/1/be/src/exec/data-source-scan-node.cc@104
PS1, Line 104:   {
             :     std::unique_lock<std::mutex> lk(lock_);
             :     ++ref_count_;
             :     if (ref_count_ > 1) {
             :       // Subsequent callers: wait for the first caller to 
finish, then reuse.
             :       open_cv_.wait(lk, [this] { return open_done_; });
             :       result->__set_scan_handle(scan_handle_);
             :       return open_status_;
             :     }
             :   }
             :
             :   // First caller: initialize the executor and open the Java 
data source outside the lock.
             :   // All N C++ scanner threads share this single connection.
             :   Status s = executor_.Init(jar_path, class_name, api_version, 
init_string);
             :   if (s.ok()) s = executor_.Open(params, result);
             :   if (s.ok()) s = Status(result->status);
             :
             :   {
             :     std::unique_lock<std::mutex> lk(lock_);
             :     if (s.ok()) scan_handle_ = result->scan_handle;
             :     open_status_ = s;
             :     open_done_ = true;
             :     open_cv_.notify_all();
             :   }
> I can remove it and in this case it shouldn't matter, but generally I think
I think the simpler the better. std::mutex is completely fine to wait on slow 
things. I think condition_variable just adds complexity for this simple case.

Probably the biggest problem is that if executor.Open() hangs indefinitely, 
then these threads hang forever. But it's probably true to a lot places 
thoughout the Impala code.



--
To view, visit http://gerrit.cloudera.org:8080/24416
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ic9f5c4ac71031b74b51bfa27ed04be10ed92e222
Gerrit-Change-Number: 24416
Gerrit-PatchSet: 1
Gerrit-Owner: Csaba Ringhofer <[email protected]>
Gerrit-Reviewer: Csaba Ringhofer <[email protected]>
Gerrit-Reviewer: Impala Public Jenkins <[email protected]>
Gerrit-Reviewer: Noemi Pap-Takacs <[email protected]>
Gerrit-Reviewer: Pranav Lodha <[email protected]>
Gerrit-Reviewer: Zoltan Borok-Nagy <[email protected]>
Gerrit-Comment-Date: Thu, 18 Jun 2026 14:39:17 +0000
Gerrit-HasComments: Yes

Reply via email to