Andrew Wong has posted comments on this change. ( 
http://gerrit.cloudera.org:8080/17725 )

Change subject: KUDU-3204: Add a metric for amount of available space
......................................................................


Patch Set 13:

(2 comments)

Seems lint is also unhappy with some line lengths.

http://gerrit.cloudera.org:8080/#/c/17725/13/src/kudu/server/server_base.cc
File src/kudu/server/server_base.cc:

http://gerrit.cloudera.org:8080/#/c/17725/13/src/kudu/server/server_base.cc@953
PS13, Line 953:   MonoTime expiry = wal_dir_space_last_check_ + 
MonoDelta::FromSeconds(
              :           FLAGS_fs_wal_dir_available_space_cache_seconds);
              :   if (MonoTime::Now() > expiry) {
              :     wal_dir_space_last_check_ = MonoTime::Now();
              :     SpaceInfo space_info_waldir;
              :     wal_dir_available_space_ = CalculateAvailableSpace(options, 
fs_manager.GetWalsRootDir(),
              :                                                        
FLAGS_fs_wal_dir_reserved_bytes,
              :                                                        
&space_info_waldir);
              :   }
              : }
I have a concern about thread safety that was actually true with the previous 
iterations. It seems like we should probably hold a lock whenever we want to 
read or write to the available space members.

Consider adding a simple_spinlock, and taking the lock only to update (not to 
calculate, given calculation may be expensive) the values. E.g.

  auto now = MonoTime::Now();
  if (MonoTime::Now() > expiry) {
    SpaceInfo space_info_waldir;
    auto wal_dir_space = CalculateAvailableSpace(options, 
fs_manager.GetWalsRootDir(),
                                                 
FLAGS_fs_wal_dir_reserved_bytes,
                                                 &space_info_waldir);
    std::lock_guard<simple_spinlock> l(lock_);
    wal_dir_space_last_check_ = now;
    wal_dir_available_space_ = wal_dir_space;
  }


Same with data dirs.


http://gerrit.cloudera.org:8080/#/c/17725/13/src/kudu/server/server_base.cc@972
PS13, Line 972:     data_dirs_available_space_ = 0;
We shouldn't be setting this to 0 every time we call this function, right?



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

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I58a7419847d080498aaf431d1dab098e1af71ad0
Gerrit-Change-Number: 17725
Gerrit-PatchSet: 13
Gerrit-Owner: Abhishek Chennaka <[email protected]>
Gerrit-Reviewer: Abhishek Chennaka <[email protected]>
Gerrit-Reviewer: Alexey Serbin <[email protected]>
Gerrit-Reviewer: Andrew Wong <[email protected]>
Gerrit-Reviewer: Attila Bukor <[email protected]>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Tidy Bot (241)
Gerrit-Comment-Date: Thu, 26 Aug 2021 20:27:16 +0000
Gerrit-HasComments: Yes

Reply via email to