Skip to content

Created Czar::FamilyMapRead function to be called on map update notif…#1034

Merged
jgates108 merged 6 commits into
tickets/DM-43715from
tickets/DM-55511
Jul 21, 2026
Merged

Created Czar::FamilyMapRead function to be called on map update notif…#1034
jgates108 merged 6 commits into
tickets/DM-43715from
tickets/DM-55511

Conversation

@jgates108

Copy link
Copy Markdown
Contributor

When the tables are updated, the notification just needs to call Czar::FamilyMapRead.

@iagaponenko iagaponenko left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would highly recommend using Copilot to prescreen the PRs.

Comment thread src/czar/Czar.h Outdated
/// been read and the request can be safely ignored.
TIMEPOINT _latestFamilyUpdate;
/// If more than this time has past, check the family map.
std::chrono::seconds _familyMapmaxUpdateWait{600};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the sake of consistency, when using the Camel-case naming convention:

_familyMapMaxUpdateWait

Comment thread src/czar/Czar.h Outdated
/// If the requestTime is > _latestFamilyUpdate (start of last read), the family map is out probably out
/// of date.
/// @return true if the family map was read.
bool FamilyMapRead(TIMEPOINT const requestTime);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two questions/comments:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's meant to be public as it can be called from anywhere when there's a notification that the tables have been changed.

First character is now lower case.

Comment thread src/czar/Czar.cc Outdated

bool Czar::FamilyMapRead(TIMEPOINT const requestTime) {
string const funcN("Czar::FamilyMapRead");
bool familyMapRead = false;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you pick a different name for the variable? It's basically (module lower/upper case first letter) the same as the name of the enclosing method. Something like:

bool mapWasUpdated = false;

Comment thread src/czar/Czar.cc
if (requestTime >= _latestFamilyUpdate || CLOCK::now() - _latestFamilyUpdate > _familyMapmaxUpdateWait) {
/// Check database for changes in worker chunk assignments and aliveness
try {
auto familyUpdateStart = CLOCK::now();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this variable here? It doesn't seem to be used anywhere. Did you mean to measure the performance of the table read operation?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the read may take a while (multiple milliseconds), the time used for comparisons needs to be before the read starts. That guarantees that updates aren't missed.

Comment thread src/czar/Czar.cc Outdated
LOGS(_log, LOG_LVL_DEBUG, funcN << " start0");
// Only one thread at a time should do this.
lock_guard familyUpdateLock(_latestFamilyUpdateMtx);
if (requestTime >= _latestFamilyUpdate || CLOCK::now() - _latestFamilyUpdate > _familyMapmaxUpdateWait) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you have a bug here:

CLOCK::now() - _latestFamilyUpdate > _familyMapmaxUpdateWait

Perhaps you meant to say this?

CLOCK::now() - _familyMapmaxUpdateWait > _latestFamilyUpdate

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might be wrong here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

latest = 8, now = 20, maxWait = 10
20 - 8 > 10 looks ok

@iagaponenko iagaponenko left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

@fritzm
fritzm force-pushed the tickets/DM-43715 branch from 4a20b9b to 07b98a6 Compare July 18, 2026 06:56
@fritzm
fritzm force-pushed the tickets/DM-55511 branch from 3ec2eb0 to 7420da1 Compare July 18, 2026 07:12
@jgates108
jgates108 marked this pull request as ready for review July 20, 2026 18:27

@fritzm fritzm left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, too -- thanks!

+1 on recommendation to have copilot review. Why not?

@jgates108
jgates108 merged commit 2bc9b5d into tickets/DM-43715 Jul 21, 2026
7 checks passed
@jgates108
jgates108 deleted the tickets/DM-55511 branch July 21, 2026 22:09
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

Successfully merging this pull request may close these issues.

3 participants