8000 Reduce the amount of exception macros by goedderz · Pull Request #14504 · arangodb/arangodb · GitHub
[go: up one dir, main page]

Skip to content

Reduce the amount of exception macros #14504

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

Merged
merged 581 commits into from
Aug 18, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
581 commits
Select commit Hold shift + click to select a range
4222682
Create agency methods and simplified RestLogHandler.cpp
Jun 11, 2021
a8592ef
Set waitForSync for replicated logs
goedderz Jun 11, 2021
5386a21
Fixed c&p error
goedderz Jun 11, 2021
1700471
More static strings.
Jun 11, 2021
32e2ef9
Set waitForSync for replicated logs
goedderz Jun 11, 2021
b3236a1
Merge branch 'devel' of https://github.com/arangodb/arangodb into fea…
goedderz Jun 11, 2021
f9a9ae6
Added tailing to coordinator.
Jun 11, 2021
4d6c0f8
Reverted changes
goedderz Jun 11, 2021
7153327
Merge branch 'feature/replication-2.0' of github.com:arangodb/arangod…
Jun 11, 2021
f9c66bd
Resign on shutdown.
Jun 11, 2021
238a64a
When dropping a collection, drop replicated logs as well.
goedderz Jun 14, 2021
fdb5fc3
Added getFirstIndexOfTerm / getLastIndexOfTerm
goedderz Jun 14, 2021
b057c15
Fixed compile errors in new maintenance tests
goedderz Jun 14, 2021
1cf4052
Fixed duplicate logIds, and related log messages
goedderz Jun 14, 2021
9848080
Select random follower.
Jun 14, 2021
3117394
Merge branch 'feature/replication-2.0' of github.com:arangodb/arangod…
Jun 14, 2021
6fc3a1b
Hide the InMemoryLog::_log member
goedderz Jun 15, 2021
f811d54
Added some assertions to a test
goedderz Jun 15, 2021
bf3550b
Adapted test to new result structure
goedderz Jun 15, 2021
397e554
Fixed JS test
goedderz Jun 15, 2021
cd65d56
Fixed compile error in c++ tests
goedderz Jun 15, 2021
89f85d3
Refactored Supervision code to make election testable.
Jun 15, 2021
4bedfb9
Added tests for checkReplicatedLog in agency.
Jun 15, 2021
6c927ad
Added test with wc = 2.
Jun 15, 2021
d8d2736
Fixing wc=2 test.
Jun 15, 2021
7975dd5
Fixed logIds
goedderz Jun 16, 2021
ddd7956
Make supervision report in Current why no leader can be elected.
Jun 16, 2021
5cd4314
Merge remote-tracking branch 'origin/devel' into feature/replication-2.0
Jun 16, 2021
f101230
Added AsyncMockLog for lonelyLeader test.
Jun 17, 2021
8604e52
A little cleanup
goedderz Jun 17, 2021
25faa0c
Added tests for database creation / deletion
goedderz Jun 17, 2021
9eb6967
Disabled FailedFollower and FailedLeader for new replication databases.
Jun 17, 2021
c537b71
Added AgencyCollectionSpecification.
Jun 17, 2021
1a57315
Stop async mock logs
goedderz Jun 21, 2021
7991960
Added detectConflict algorithm that is used on the follower to detect…
Jun 21, 2021
a7463c1
Enabled optimization for conflict detection.
Jun 22, 2021
d89c0cd
Added more logging.
Jun 22, 2021
1b6f63a
Moved log create/drop logic from vocbase to log manager, and added a …
goedderz Jun 17, 2021
d33c293
Added the collection name to the replicated log LogContext
goedderz Jun 17, 2021
38e332e
Minor changes
goedderz Jun 17, 2021
0dc517c
Fix compile errors with tsan
goedderz Jun 22, 2021
a2cffaf
Added UnshackledMutex
goedderz Jun 22, 2021
d5a1eaf
Use UnshackledMutex in LogCore for _operationMutex
goedderz Jun 22, 2021
15950e4
Make sure _stopping is initialized before the thread is started
goedderz Jun 22, 2021
932483a
Fixed problems in concurrent test
goedderz Jun 22, 2021
b096c09
Use a different immer memory policy, to work around a concurrency iss…
goedderz Jun 22, 2021
d43338d
Use transparent functor
goedderz Jun 22, 2021
359e1dc
Added missing dependency
goedderz Jun 22, 2021
9a24222
Fixed an assertion
goedderz Jun 23, 2021
c529f18
No longer call `insertAsync` for empty AppendEntriesRequests, and hol…
goedderz Jun 23, 2021
63f3d3a
Added another assertion in the AsyncMockLog
goedderz Jun 23, 2021
19ffb17
Cleanup rest handler.
Jun 24, 2021
790a115
Added CollectionGroups to ClusterInfo.
Jun 24, 2021
cf447d7
Avoid jslint error
goedderz Jun 28, 2021
a0311c4
Made collection name optional in ensureReplicatedLog.
Jun 28, 2021
21250d0
Merge remote-tracking branch 'origin/devel' into feature/replication-2.0
Jun 28, 2021
54023ce
Replace lastAckedIndex with lastAckedEntry having a meaningful term.
Jun 29, 2021
add04ec
Merge branch 'devel' of github.com:arangodb/arangodb into feature/gua…
goedderz Jun 29, 2021
c6668d3
Minor changes
goedderz Jun 29, 2021
3dc12ed
Merge branch 'devel' of github.com:arangodb/arangodb into feature/rep…
goedderz Jun 29, 2021
159a458
Merge branch 'feature/guarded-mutex' of github.com:arangodb/arangodb …
goedderz Jun 29, 2021
4dbb050
Cleaned up some TODOs.
Jun 29, 2021
15c0c93
More TODO cleanup.
Jun 29, 2021
b63e404
noexcept in finally.
Jun 29, 2021
857acbb
Made finally exception safe.
Jun 29, 2021
9587f44
Require admin access to database for log api. Only enabled in maintai…
Jun 29, 2021
ea89666
Added missing tests
goedderz Jun 29, 2021
e2dfe36
Added a feature flag for Replication2
goedderz Jun 29, 2021
a06fbfc
Replaced leaderId by optional because leader is optional.
Jul 1, 2021
9490a3d
Added maintenance tests.
Jul 2, 2021
1150d86
More tests for maintenanceMore tests for maintenance..
Jul 2, 2021
7d0da23
Fixed maintenance code.
Jul 2, 2021
a3bbd09
Extracted action code into algorithms to make it unit testable.
Jul 2, 2021
8401ad2
More tests for maintenance action code.
Jul 5, 2021
33ce3fd
Replaced references for replicated logs by shared ptrs.
Jul 5, 2021
7a989c0
Disable functional tests when replication2 is disabled
goedderz Jul 6, 2021
3398cfd
Cleanup some code paths.
Jul 6, 2021
ce98e73
More code cleanup.
Jul 6, 2021
ec1e8a5
Moved FeatureFlag.cpp/.h
goedderz Jul 6, 2021
edc7cf9
Fixed a few compile errors
goedderz Jul 6, 2021
70d462c
Fixed compile errors in the tests
goedderz Jul 6, 2021
d4be0ec
More code cleanup in LogFollower.
Jul 6, 2021
56e831f
Fixed a warning
goedderz Jul 6, 2021
5f51904
More code clean up of follower.
Jul 6, 2021
6113d06
Fixed bug in messageId handling.
Jul 6, 2021
7c50d7d
Cleanup more code.
Jul 6, 2021
e391089
Renamed messages.h to NetworkMessages.h
Jul 6, 2021
16856c0
Fixing wrong assertion.
Jul 6, 2021
4175c15
Move MeasureTimeGuard to common header.
Jul 7, 2021
9e43467
Removed TermData and use LogConfig instead. Clean up code at places.
Jul 7, 2021
25b06f4
Build wrapper around LogStatus.
Jul 7, 2021
95585ca
Fixed tests and compilation.
Jul 7, 2021
a736dd3
Allow loading a replication 2 db, even if replication 2 is disabled
goedderz Jul 7, 2021
f473421
Add replication 2 tests to arangodbtests binary, and make building ar…
goedderz Jul 7, 2021
b86e5bb
Moved Status Objects into LogStatus.h
Jul 7, 2021
3f9314f
Added more forward declarations to include the api headers less.
Jul 7, 2021
a2cb01c
PR clean up.
Jul 7, 2021
5817591
Refactored some headers to optimize includes.
Jul 8, 2021
1c922e0
Fixing StorageEngineMock.
Jul 8, 2021
af4768c
Added some mis ing declarations
goedderz Jul 8, 2021
bbf6dfe
Started writing a test for UnshackledMutex
goedderz Jul 8, 2021
040a4b0
Optimized DBServerAgencySync.h
Jul 8, 2021
5a463c9
Added peek() on LogIterators
goedderz Jul 8, 2021
419780d
Revert "Added peek() on LogIterators"
goedderz Jul 8, 2021
d81df02
Merge remote-tracking branch 'origin/devel' into feature/replication-2.0
Jul 8, 2021
aa2245b
Minor changes
goedderz Jul 8, 2021
c610400
Got rid of unnecessarily passed weak_ptr parentLogs
goedderz Jul 8, 2021
91940ad
Removed unused includes.
Jul 8, 2021
731e8ad
Collected some changes from replication 2.0 PR.
Jul 8, 2021
b3ae831
Merge remote-tracking branch 'origin/feature/replicated-log-companion…
Jul 8, 2021
18b6567
Added exception header.
Jul 8, 2021
12a307c
Merge remote-tracking branch 'origin/feature/replicated-log-companion…
Jul 8, 2021
f0f925b
More code that is not related to replicated logs.
Jul 8, 2021
43313c4
Made LogIterator peek()able
goedderz Jul 8, 2021
96b89da
Added readEnd() to PersistedLog and RocksDBLog
goedderz Jul 8, 2021
5aa99be
Reverted accidental change
goedderz Jul 8, 2021
7cc75e5
Revert "Made LogIterator peek()able"
goedderz Jul 8, 2021
fa0af53
Revert "Added readEnd() to PersistedLog and RocksDBLog"
goedderz Jul 8, 2021
57c36d9
Merge remote-tracking branch 'origin/devel' into feature/replication-2.0
Jul 8, 2021
b4ff84c
Merge remote-tracking branch 'origin/devel' into feature/replicated-l…
Jul 8, 2021
16ae7f2
Merge remote-tracking branch 'origin/feature/replicated-log-companion…
Jul 8, 2021
56d8eaf
Clean up LogicalCollection changes.
Jul 8, 2021
14b438d
Made a comment out of a TODO note
goedderz Jul 8, 2021
6b847ae
Revert "Run gtest binary arangodbtests_replication2"
Jul 8, 2021
15f6f57
Added modifications on metrics feature api.
Jul 8, 2021
f310f05
Merge remote-tracking branch 'origin/feature/replicated-log-companion…
Jul 8, 2021
2348a56
Reverted Collection changes.
Jul 8, 2021
358dccd
Reverted collection code.
Jul 8, 2021
7ea920d
Added path components.
Jul 8, 2021
5dcc68f
Merge remote-tracking branch 'origin/feature/replicated-log-companion…
Jul 8, 2021
8fe6c1d
Merge remote-tracking branch 'origin/feature/replicated-log-companion…
Jul 8, 2021
9b42045
Fixing clusterinfo.
Jul 8, 2021
b0568ed
Reverted ClusterInfo changes.
Jul 8, 2021
3ee74a6
Merge remote-tracking branch 'origin/feature/replicated-log-companion…
Jul 8, 2021
db4c458
More reverts in logical collection.
Jul 8, 2021
f99e800
Merge remote-tracking branch 'origin/feature/replicated-log-companion…
Jul 8, 2021
3457738
Merge remote-tracking branch 'origin/feature/replication-2.0' into fe…
Jul 8, 2021
2e03ee9
Reverted more of ClusterInfo.
Jul 8, 2021
09f0db3
Fixing Maintenance Tests.
Jul 8, 2021
da00636
Merge remote-tracking branch 'origin/feature/replicated-log-companion…
Jul 8, 2021
4fe1fa7
Cleanup in Maintenance and ClusterInfo.
Jul 8, 2021
8f22481
Merge remote-tracking branch 'origin/feature/replicated-log-companion…
Jul 8, 2021
13bef2c
Merge remote-tracking branch 'origin/feature/replication-2.0' into fe…
Jul 8, 2021
4bfd458
Revert IRSearch Tests.
Jul 8, 2021
52b76b3
Minor changes from review
goedderz Jul 9, 2021
d0ebb4c
Remove code duplication as suggested in the review
goedderz Jul 9, 2021
8e17cc0
Made FATAL_ERROR_(EXIT|ABORT) exception safe and replaced the macros …
goedderz Jul 12, 2021
5d08a49
Fixed some compile errors
goedderz Jul 12, 2021
fcfffe7
Completed UnshackledMutexTest
goedderz Jul 12, 2021
1ed681f
Merge branch 'feature/replicated-log-companion-pr' into feature/repli…
goedderz Jul 12, 2021
7b75ac2
Merge branch 'feature/guarded-mutex' of https://github.com/arangodb/a…
goedderz Jul 12, 2021
45e466c
Merge branch 'feature/replicated-log-companion-pr' of https://github.…
goedderz Jul 12, 2021
d511074
Create the AppendEntriesRequest after the optional delay, so it can u…
goedderz Jul 8, 2021
bab222f
Merge branch 'devel' of https://github.com/arangodb/arangodb into fea…
goedderz Jul 12, 2021
2213793
Merge branch 'feature/replicated-log-companion-pr' of https://github.…
goedderz Jul 12, 2021
cec1f26
Fixed compile and linker errors
goedderz Jul 12, 2021
49cf5a0
Resolve ambiguous call
goedderz Jul 12, 2021
335880d
Resolve ambiguous call
goedderz Jul 12, 2021
24a7b55
Replace unlikely
goedderz Jul 12, 2021
2711672
🤦
goedderz Jul 13, 2021
0afdf78
Added assertions to clarify a constructor's mode of operation
goedderz Jul 13, 2021
8d27093
Added assertions to clarify a constructor's mode of operation
goedderz Jul 13, 2021
f6e7453
Added retry to SchedulerExecutor for RocksDBLogPersistor. Implemented…
Jul 13, 2021
968854c
Changed and added an assertion to clarify the most important property
goedderz Jul 13, 2021
99e2b2f
Added some comments
goedderz Jul 13, 2021
179cc0c
Merge branch 'feature/replicated-log-companion-pr' of github.com:aran…
goedderz Jul 13, 2021
c63e834
Fix test compilation.
Jul 13, 2021
658603b
Renamed metrics as suggested by promtool
goedderz Jul 13, 2021
0bb98db
Fixed compile error in tests
goedderz Jul 13, 2021
0ea5fc4
Merge branch 'feature/replication-2.0-pr' of github.com:arangodb/aran…
goedderz Jul 13, 2021
13eb2c7
Made queue code exception safe.
Jul 13, 2021
9c04337
Added exponential backoff.
Jul 13, 2021
638bf83
Fixed copyright header
goedderz Jul 13, 2021
95901b4
Merge branch 'feature/replicated-log-companion-pr' of github.com:aran…
goedderz Jul 13, 2021
339b747
Fixed copyright headers
goedderz Jul 13, 2021
28ac084
Merge branch 'feature/replication-2.0-pr' of github.com:arangodb/aran…
goedderz Jul 13, 2021
d38819c
Renamed RocksDBLog to RocksDBPersistedLog.
Jul 13, 2021
72dd8ba
Replaced prevLogIndex/prevLogTerm by prevLogEntry :: TermIndexPair. R…
Jul 13, 2021
c879bcb
Resolved a TODO
goedderz Jul 13, 2021
5f23f0b
Merge branch 'feature/replication-2.0-pr' of github.com:arangodb/aran…
goedderz Jul 13, 2021
35b0043
Fixing failover.
Jul 14, 2021
4f7cad3
A little cleanup around RocksDBLogPersistor
goedderz Jul 14, 2021
28520ee
Merge branch 'feature/replication-2.0-pr' of https://github.com/arang…
goedderz Jul 14, 2021
f4580aa
Merge branch 'devel' of https://github.com/arangodb/arangodb into fea…
goedderz Jul 14, 2021
11b0abe
Make updateReplicatedLog noexcept.
Jul 14, 2021
723ce02
Removed a superfluous try-catch block, and resolved a TODO
goedderz Jul 14, 2021
1ed2419
Reduce the amount of exception macros
goedderz Jul 14, 2021
460e132
Removed some code
goedderz Jul 15, 2021
d3bd17d
Replaced a macro missed before
goedderz Jul 15, 2021
0880468
Fixes
goedderz Jul 15, 2021
a7e456f
Update lib/Basics/ResultError.cpp
goedderz Jul 16, 2021
a90d45e
Addressed review comments
goedderz Jul 19, 2021
98783e3
Merge remote-tracking branch 'origin/devel' into feature/replication-…
Jul 19, 2021
13c4811
Fixed non-maintainer-mode
goedderz Jul 19, 2021
ed74d4e
Reverted changes in ShardingInfo that are not yet necessary
goedderz Jul 19, 2021
ff8127a
Removed DelayedLogLeader
goedderz Jul 19, 2021
fe69d8f
Some minor changes
goedderz Jul 19, 2021
eb17e17
Rename runAsyncStep to triggerAsyncReplication
goedderz Jul 19, 2021
6291151
LogLeader::insert now calls triggerAsyncReplication by default
goedderz Jul 19, 2021
3cca504
Added test that checks for correct commit behavior for entries from p…
Jul 20, 2021
f2a6e14
Fixing tests. Added ChangeStream test.
Jul 20, 2021
fa36999
Fixing off-by-one error in InMemoryLog. Fixing waitForIterator return…
Jul 20, 2021
6c752ba
Move PrevTermCommitTest to the correct sources in cmake
goedderz Jul 20, 2021
76a022f
Do not commit log entries from previous terms
goedderz Jul 20, 2021
2d72668
Increase Replication2's default log level to INFO
goedderz Jul 20, 2021
c537b3f
Change the test so it fails with the usual gtest assertions, instead …
goedderz Jul 20, 2021
2f05f8b
Wrapped LogEntry into InMemoryLogEntry
goedderz Jul 21, 2021
9bd22e6
Insert an empty LogEntry in LogLeader::construct
goedderz Jul 22, 2021
2a3456d
[WIP] Separated internal and user-facing log entries and iterators
goedderz Jul 26, 2021
9229c63
Apply suggestions from code review
Jul 27, 2021
dd07391
More changes from code review.
Jul 27, 2021
6396c12
Added code for loading PersistingLogEntries from disk.
Jul 27, 2021
1ec2db9
Added limit to rest api. Skip private log entries and wait for first …
Jul 27, 2021
68fa272
Fixed issues from code review.
Jul 28, 2021
7569596
Apply suggestions from code review
Jul 28, 2021
d54d36b
Added and fixed tests. Applied suggestions from code review.
Jul 28, 2021
1a3b80a
Apply suggestions from code review
Jul 28, 2021
4998603
Moved extractors to header files and use them exclusively.
Jul 28, 2021
a23cc59
Merge remote-tracking branch 'origin/devel' into feature/replication-…
Jul 28, 2021
25ef544
Fixing compile issue introduced by github suggestion.
Jul 28, 2021
f59d3a4
Remove useless test.
Jul 28, 2021
e4488c3
Fixing checkLogIds.py by ignoring the correct file.
Jul 28, 2021
8d89b0f
Renamed LogParticipantI to ILogParticipant.
Jul 28, 2021
ad0efd0
Apply suggestions from code review
Jul 30, 2021
3339c31
Merge remote-tracking branch 'origin/devel' into feature/replication-…
Jul 30, 2021
5ddb06d
Implemented suggestions from code review.
Jul 30, 2021
b59503a
Fix typo.
Aug 2, 2021
5e0efb8
Added comment on implement_compare. Added logging to checkReplicatedLog.
Aug 2, 2021
2a3027a
Merge remote-tracking branch 'origin/devel' into feature/replication-…
Aug 3, 2021
672afd5
Added commit index as static string.
Aug 3, 2021
3719217
Renamed splice to slice. Fixed saturatedDecrement.
Aug 3, 2021
7df53d6
Simplify log thread allocation.
Aug 3, 2021
c47404a
Review: Wrote out microseconds in metric documentation
goedderz Aug 3, 2021
3bfa5d4
Review: Removed useless return values
goedderz Aug 3, 2021
b35e708
Merge branch 'devel' of github.com:arangodb/arangodb into feature/rep…
goedderz Aug 3, 2021
88b4d1e
Fixing bugs found during code review. Use UnshackledMutex in more pla…
Aug 4, 2021
6a2f111
Fixing RestLogHandler. Returned only quorum data that contains the wr…
Aug 5, 2021
b4c9a85
Small changes from code review.
Aug 5, 2021
0f33c96
Applied suggestions from code review.
Aug 6, 2021
ddd19ce
Apply suggestions from code review
Aug 6, 2021
2714e12
Applied more suggestions. Code clean up. LogTerm/LogIndex always by-v…
Aug 9, 2021
48e1cc9
Apply suggestions from code review
Aug 9, 2021
2a92412
Added forward declaration of friend operators.
Aug 9, 2021
1a2d1c4
Removed dependency on application server.
Aug 9, 2021
72d3dba
Remove wrong static assertion.
Aug 10, 2021
b141ab1
Merge commit '72d3dba13f07a96894de2d59a50e2fe79478f06c' into feature/…
goedderz Aug 17, 2021
3b20a4e
Merge commit 'c3c390b8b0db30ba5917ba655fddee96807526da^' into feature…
goedderz Aug 17, 2021
bd07a6e
Merge commit 'c3c390b8b0db30ba5917ba655fddee96807526da' into tmp
goedderz Aug 17, 2021
83bb465
Merge branch 'tmp' into feature/reduce-macros
goedderz Aug 17, 2021
3ea28f6
Merge remote-tracking branch 'origin/devel' into feature/reduce-macros
goedderz Aug 17, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Minor changes
  • Loading branch information
goedderz committed Jul 8, 2021
commit aa2245b04a0c41a6e7b64542a09145b098aa18cc
8 changes: 8 additions & 0 deletions arangod/Replication2/ReplicatedLog/LogCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ auto replication2::operator<<(std::ostream& os, const LogIndex& idx) -> std::ost
return os << idx.value;
}

auto LogIndex::saturatedDecrement() const noexcept -> LogIndex {
if (value > 0) {
return LogIndex{value - 1};
}

return LogIndex{0};
}

LogEntry::LogEntry(LogTerm logTerm, LogIndex logIndex, LogPayload payload)
: _logTerm{logTerm}, _logIndex{logIndex}, _payload{std::move(payload)} {}

Expand Down
2 changes: 2 additions & 0 deletions arangod/Replication2/ReplicatedLog/LogCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ struct LogIndex : implement_compare<LogIndex> {
constexpr explicit LogIndex(std::uint64_t value) noexcept : value{value} {}
std::uint64_t value;

[[nodiscard]] auto saturatedDecrement() const noexcept -> LogIndex;

[[nodiscard]] auto operator<=(LogIndex) const -> bool;

auto operator+(std::uint64_t delta) const -> LogIndex;
Expand Down
35 changes: 16 additions & 19 deletions arangod/Replication2/ReplicatedLog/LogLeader.cpp
F438
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,8 @@ void replicated_log::LogLeader::executeAppendEntriesRequests(

for (auto& it : requests) {
if (it.has_value()) {
// Capture self(shared_from_this()) instead of this
// additionally capture a weak pointer that will be locked
// when the request returns. If the locking is successful
// we are still in the same term.
delayedFuture(it->_executionDelay).thenFinal([it = it, logMetrics](auto&&) mutable {
// we need to lock here, because we access _follower
// Let's check whether our log is still there, and abort otherwise
auto guard = it->_parentLog.lock();
if (guard == nullptr) {
LOG_TOPIC("de312", DEBUG, Logger::REPLICATION2)
Expand All @@ -184,8 +180,11 @@ void replicated_log::LogLeader::executeAppendEntriesRequests(
LOG_CTX("1b0ec", TRACE, it->_follower->logContext)
<< "sending append entries, messageId = " << messageId;
auto startTime = std::chrono::steady_clock::now();
// Capture a weak pointer `parentLog` that will be locked
// when the request returns. If the locking is successful
// we are still in the same term.
it->_follower->_impl->appendEntries(std::move(it->_request))
.thenFinal([parentLog = it->_parentLog, &follower = *it->_follower,
.thenFinal([parentLog = it->_parentLog, follower = it->_follower,
lastIndex = it->_lastIndex, currentCommitIndex = it->_currentCommitIndex,
currentTerm = it->_currentTerm, messageId = messageId, startTime,
logMetrics = logMetrics](futures::Try<AppendEntriesResult>&& res) noexcept {
Expand All @@ -199,18 +198,18 @@ void replicated_log::LogLeader::executeAppendEntriesRequests(
using namespace std::chrono_literals;
auto const duration = endTime - startTime;
self->_logMetrics->replicatedLogAppendEntriesRttUs->count(duration / 1us);
LOG_CTX("8ff44", TRACE, follower.logContext)
LOG_CTX("8ff44", TRACE, follower->logContext)
<< "received append entries response, messageId = " << messageId;
auto [preparedRequests, resolvedPromises] = std::invoke(
[&]() -> std::pair<std::vector<std::optional<PreparedAppendEntryRequest>>, ResolvedPromiseSet> {
auto guarded = self->acquireMutex();
if (!guarded->_didResign) {
// Is throwing the right thing to do here? - No, we are in a finally
return guarded->handleAppendEntriesResponse(
parentLog, follower, lastIndex, currentCommitIndex, currentTerm,
parentLog, *follower, lastIndex, currentCommitIndex, currentTerm,
std::move(res), endTime - startTime, messageId);
} else {
LOG_CTX("da116", DEBUG, follower.logContext)
LOG_CTX("da116", DEBUG, follower->logContext)
<< "received response from follower but leader "
"already resigned, messageId = "
<< messageId;
Expand Down Expand Up @@ -500,7 +499,7 @@ auto replicated_log::LogLeader::GuardedLeaderData::prepareAppendEntry(
req.leaderTerm = _self._currentTerm;
req.leaderId = _self._id;
req.waitForSync = _self._config.waitForSync;
req.messageId = ++follower.lastSendMessageId;
req.messageId = ++follower.lastSentMessageId;

if (lastAcked) {
req.prevLogIndex = lastAcked->logIndex();
Expand Down Expand Up @@ -534,7 +533,7 @@ auto replicated_log::LogLeader::GuardedLeaderData::prepareAppendEntry(

follower.requestInFlight = true;
auto preparedRequest = PreparedAppendEntryRequest{};
preparedRequest._follower = std::shared_ptr<FollowerInfo>(parentLog.lock(), &follower);
preparedRequest._follower = std::shared_ptr<FollowerInfo>(_self.shared_from_this(), &follower);
preparedRequest._currentTerm = _self._currentTerm;
preparedRequest._currentCommitIndex = currentCommitIndex;
preparedRequest._lastIndex = lastIndex;
Expand Down Expand Up @@ -569,7 +568,7 @@ auto replicated_log::LogLeader::GuardedLeaderData::handleAppendEntriesResponse(

follower._lastRequestLatency = latency;

if (follower.lastSendMessageId == messageId) {
if (follower.lastSentMessageId == messageId) {
LOG_CTX("35a32", TRACE, follower.logContext)
<< "received message " << messageId << " - no other requests in flight";
// there is no request in flight currently
Expand All @@ -578,7 +577,7 @@ auto replicated_log::LogLeader::GuardedLeaderData::handleAppendEntriesResponse(
if (res.hasValue()) {
auto& response = res.get();
TRI_ASSERT(messageId == response.messageId);
if (follower.lastSendMessageId == response.messageId) {
if (follower.lastSentMessageId == response.messageId) {
LOG_CTX("35134", TRACE, follower.logContext)
<< "received append entries response, messageId = " << response.messageId
<< ", errorCode = " << to_string(response.errorCode)
Expand All @@ -596,26 +595,23 @@ auto replicated_log::LogLeader::GuardedLeaderData::handleAppendEntriesResponse(
case AppendEntriesErrorReason::NO_PREV_LOG_MATCH:
follower.numErrorsSinceLastAnswer = 0;
TRI_ASSERT(response.conflict.has_value());
follower.lastAckedEntry.index = response.conflict.value().index;
follower.lastAckedEntry.index = response.conflict.value().index.saturatedDecrement();
LOG_CTX("33c6d", DEBUG, follower.logContext)
<< "reset last acked index to " << follower.lastAckedEntry;
if (follower.lastAckedEntry.index > LogIndex{0}) {
follower.lastAckedEntry.index = LogIndex{follower.lastAckedEntry.index.value - 1};
}
break;
default:
LOG_CTX("1bd0b", DEBUG, follower.logContext)
<< "received error from follower, reason = " << to_string(response.reason)
<< " message id = " << messageId;
follower.numErrorsSinceLastAnswer += 1;
++follower.numErrorsSinceLastAnswer;
}
}
} else {
LOG_CTX("056a8", DEBUG, follower.logContext)
<< "received outdated response from follower "
<< follower._impl->getParticipantId() << ": "
<< response.messageId << ", expected " << messageId
<< ", latest " << follower.lastSendMessageId;
<< ", latest " << follower.lastSentMessageId;
}
} else if (res.hasException()) {
++follower.numErrorsSinceLastAnswer;
Expand All @@ -638,6 +634,7 @@ auto replicated_log::LogLeader::GuardedLeaderData::handleAppendEntriesResponse(
TRI_ASSERT(false);
FATAL_ERROR_EXIT();
}

// try sending the next batch
return std::make_pair(prepareAppendEntries(parentLog), std::move(toBeResolved));
}
Expand Down
11 changes: 10 additions & 1 deletion arangod/Replication2/ReplicatedLog/LogLeader.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class LogLeader : public std::enable_shared_from_this<LogLeader>, public LogPart
std::shared_ptr<AbstractFollower> _impl;
TermIndexPair lastAckedEntry = TermIndexPair{LogTerm{0}, LogIndex{0}};
LogIndex lastAckedCommitIndex = LogIndex{0};
MessageId lastSendMessageId{0};
MessageId lastSentMessageId{0};
std::size_t numErrorsSinceLastAnswer = 0;
AppendEntriesErrorReason lastErrorReason = AppendEntriesErrorReason::NONE;
LoggerContext const logContext;
Expand Down Expand Up @@ -152,11 +152,20 @@ class LogLeader : public std::enable_shared_from_this<LogLeader>, public LogPart

struct PreparedAppendEntryRequest {
// TODO Write a constructor, delete the default constructor
// TODO Make this a weak_ptr. It will always be an alias of _parentLog.
std::shared_ptr<FollowerInfo> _follower;
// TODO Currently, the AppendEntriesRequest is built before we wait for
// the _executionDelay. This is suboptimal in the sense that we might
// be able to squeeze some additional log entries in the request if we
// build it only after the wait.
// So the task is to remove _request from this struct, and only build
// it right before the request should actually be sent.
AppendEntriesRequest _request;
std::weak_ptr<LogLeader> _parentLog;
TermIndexPair _lastIndex;
LogIndex _currentCommitIndex;
// TODO _currentTerm is probably not necessary here, we could read it in
// executeAppendEntries, as we don't need to acquire the lock to read it.
LogTerm _currentTerm;
std::chrono::steady_clock::duration _executionDelay;
};
Expand Down
0