Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Review fixes and refactor: #6

Merged
merged 2 commits into from
Aug 29, 2024

Conversation

mtrippled
Copy link

@mtrippled mtrippled commented Aug 29, 2024

  1. refactor filtering of validations to specifically avoid
    concurrent checkAccept() calls for the same validation hash.
  2. Log when duplicate concurrent inbound ledger and validation requests
    are filtered.
  3. RAII for containers that track concurrent inbound ledger and
    validation requests.
  4. Comment on when to asynchronously acquire inbound ledgers, which
    is possible to be always OK, but should have further review.

High Level Overview of Change

Context of Change

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactor (non-breaking change that only restructures code)
  • Performance (increase or change in throughput and/or latency)
  • Tests (you added tests for code that already exists, or your new feature included in this PR)
  • Documentation update
  • Chore (no impact to binary, e.g. .gitignore, formatting, dropping support for older tooling)
  • Release

API Impact

  • Public API: New feature (new methods and/or new fields)
  • Public API: Breaking change (in general, breaking changes should only impact the next api_version)
  • libxrpl change (any change that may affect libxrpl or dependents of libxrpl)
  • Peer protocol change (must be backward compatible or bump the peer protocol version)

This change is Reviewable

1) refactor filtering of validations to specifically avoid
   concurrent checkAccept() calls for the same validation hash.
2) Log when duplicate concurrent inbound ledger and validation requests
   are filtered.
3) RAII for containers that track concurrent inbound ledger and
   validation requests.
4) Comment on when to asynchronously acquire inbound ledgers, which
   is possible to be always OK, but should have further review.
@mtrippled mtrippled force-pushed the refactor-validation branch from f15ac51 to 7503b41 Compare August 29, 2024 20:56
Copy link

@bachase bachase left a comment

Choose a reason for hiding this comment

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

LGTM as a hotfix

#include <vector>

namespace ripple {

class Application;

enum class BypassAccept { FALSE, TRUE };
Copy link
Owner

Choose a reason for hiding this comment

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

The FALSE and TRUE keywords are #defined on Windows, which messes up building this.

Suggested change
enum class BypassAccept { FALSE, TRUE };
enum class BypassAccept : bool { no = false, yes };

Copy link
Owner

Choose a reason for hiding this comment

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

I pushed this change to the branch so I can go ahead and merge this pull request. and let testing proceed.

Comment on lines 159 to 181
std::unique_lock lock(acquiresMutex_);
if (pendingAcquires_.contains(hash))
return;
pendingAcquires_.insert(hash);
lock.unlock();
acquire(hash, seq, reason);
try
{
if (pendingAcquires_.contains(hash))
return;
pendingAcquires_.insert(hash);
lock.unlock();
acquire(hash, seq, reason);
}
catch (std::exception const& e)
{
JLOG(j_.warn())
<< "Exception thrown for acquiring new inbound ledger " << hash
<< ": " << e.what();
}
catch (...)
{
JLOG(j_.warn())
<< "Unknown exception thrown for acquiring new inbound ledger "
<< hash;
}
lock.lock();
pendingAcquires_.erase(hash);
Copy link
Owner

Choose a reason for hiding this comment

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

The manual calls to unlock and lock still being here are rubbing me the wrong way. What about:

Suggested change
std::unique_lock lock(acquiresMutex_);
if (pendingAcquires_.contains(hash))
return;
pendingAcquires_.insert(hash);
lock.unlock();
acquire(hash, seq, reason);
try
{
if (pendingAcquires_.contains(hash))
return;
pendingAcquires_.insert(hash);
lock.unlock();
acquire(hash, seq, reason);
}
catch (std::exception const& e)
{
JLOG(j_.warn())
<< "Exception thrown for acquiring new inbound ledger " << hash
<< ": " << e.what();
}
catch (...)
{
JLOG(j_.warn())
<< "Unknown exception thrown for acquiring new inbound ledger "
<< hash;
}
lock.lock();
pendingAcquires_.erase(hash);
try
{
{
std::unique_lock lock(acquiresMutex_);
if (pendingAcquires_.contains(hash))
return;
pendingAcquires_.insert(hash);
}
acquire(hash, seq, reason);
}
catch (std::exception const& e)
{
JLOG(j_.warn())
<< "Exception thrown for acquiring new inbound ledger " << hash
<< ": " << e.what();
}
catch (...)
{
JLOG(j_.warn())
<< "Unknown exception thrown for acquiring new inbound ledger "
<< hash;
}
std::unique_lock lock(acquiresMutex_);
pendingAcquires_.erase(hash);

Copy link
Author

Choose a reason for hiding this comment

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

Sure, go ahead. Can also be lock_guard in that case if you want.

Copy link
Owner

Choose a reason for hiding this comment

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

I'm fine with leaving this as-is for now, but check out 7a24764

Copy link
Owner

@ximinez ximinez left a comment

Choose a reason for hiding this comment

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

Pending CI completion

@ximinez ximinez merged commit 8847f72 into ximinez:pr/2.2.2-rc1 Aug 29, 2024
16 of 17 checks passed
ximinez added a commit that referenced this pull request Aug 29, 2024
* origin/pr/2.2.2-rc1:
  Review fixes and refactor: (#6)
ximinez added a commit that referenced this pull request Aug 30, 2024
ximinez added a commit that referenced this pull request Aug 30, 2024
* origin/pr/2.2.2-rc1:
  Set version to 2.2.2-rc2
  fixup! Review fixes and refactor: (#6)
  Review fixes and refactor: (#6)
ximinez pushed a commit that referenced this pull request Sep 2, 2024
1) refactor filtering of validations to specifically avoid
   concurrent checkAccept() calls for the same validation hash.
2) Log when duplicate concurrent inbound ledger and validation requests
   are filtered.
3) RAII for containers that track concurrent inbound ledger and
   validation requests.
4) Comment on when to asynchronously acquire inbound ledgers, which
   is possible to be always OK, but should have further review.
ximinez added a commit that referenced this pull request Sep 2, 2024
* origin/pr/2.2.2-rc1:
  Set version to 2.2.2-rc2
  fixup! Review fixes and refactor: (#6)
  Review fixes and refactor: (#6)
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