File tree Expand file tree Collapse file tree 5 files changed +37
-6
lines changed Expand file tree Collapse file tree 5 files changed +37
-6
lines changed Original file line number Diff line number Diff line change 1
1
v3.7.13 (XXXX-XX-XX)
2
2
--------------------
3
3
4
+ * APM-107: Added metric "rocksdb_read_only" to determine whether RocksDB is
5
+ currently in read-only mode due to a background error. The metric will have a
6
+ value of "1" if RocksDB is in read-only mode and "0" if RocksDB is in normal
7
+ operations mode. If the metric value is "1" it means all writes into RocksDB
8
+ will fail, so inspecting the logfiles and acting on the actual error situation
9
+ is required.
10
+
4
11
* Add following term ids, which prevents old synchronous replication requests to
5
12
be accepted after a follower was dropped and has gotten in sync again.
6
13
This makes the chaos tests which delay synchronous replication requests more
Original file line number Diff line number Diff line change 28
28
29
29
namespace arangodb {
30
30
31
+ RocksDBBackgroundErrorListener::RocksDBBackgroundErrorListener ()
32
+ : _called(false ) {}
33
+
31
34
RocksDBBackgroundErrorListener::~RocksDBBackgroundErrorListener () = default ;
32
35
33
36
void RocksDBBackgroundErrorListener::OnBackgroundError (rocksdb::BackgroundErrorReason reason,
@@ -37,10 +40,8 @@ void RocksDBBackgroundErrorListener::OnBackgroundError(rocksdb::BackgroundErrorR
37
40
return ;
38
41
}
39
42
40
- if (!_called) {
41
- _called = true ;
42
-
43
- std::string operation = " unknown" ;
43
+ if (!_called.exchange (true )) {
44
+ char const * operation = " unknown" ;
44
45
switch (reason) {
45
46
case rocksdb::BackgroundErrorReason::kFlush : {
46
47
operation = " flush" ;
@@ -67,4 +68,11 @@ void RocksDBBackgroundErrorListener::OnBackgroundError(rocksdb::BackgroundErrorR
67
68
}
68
69
}
69
70
71
+ void RocksDBBackgroundErrorListener::OnErrorRecoveryCompleted (rocksdb::Status /* old_bg_error */ ) {
72
+ _called.store (false , std::memory_order_relaxed);
73
+
74
+ LOG_TOPIC (" 8ff56" , WARN, Logger::ROCKSDB)
75
+ << " RocksDB resuming operations after background error" ;
76
+ }
77
+
70
78
} // namespace arangodb
Original file line number Diff line number Diff line change 27
27
#include < rocksdb/db.h>
28
28
#include < rocksdb/listener.h>
29
29
30
+ #include < atomic>
31
+
30
32
namespace arangodb {
31
33
32
34
class RocksDBBackgroundErrorListener : public rocksdb ::EventListener {
33
35
public:
36
+ RocksDBBackgroundErrorListener ();
34
37
virtual ~RocksDBBackgroundErrorListener ();
35
38
36
39
void OnBackgroundError (rocksdb::BackgroundErrorReason reason, rocksdb::Status* error) override ;
40
+ void OnErrorRecoveryCompleted (rocksdb::Status /* old_bg_error */ ) override ;
41
+
42
+ bool called () const noexcept {
43
+ return _called.load (std::memory_order_relaxed);
44
+ }
37
45
38
46
private:
39
- bool _called = false ;
47
+ std::atomic< bool > _called;
40
48
}; // class RocksDBThrottle
41
49
42
50
} // namespace arangodb
Original file line number Diff line number Diff line change @@ -642,7 +642,8 @@ void RocksDBEngine::start() {
642
642
_options.listeners .push_back (_shaListener);
643
643
} // if
644
644
645
- _options.listeners .push_back (std::make_shared<RocksDBBackgroundErrorListener>());
645
+ _errorListener = std::make_shared<RocksDBBackgroundErrorListener>();
646
+ _options.listeners .push_back (_errorListener);
646
647
647
648
if (opts._totalWriteBufferSize > 0 ) {
648
649
_options.db_write_buffer_size = opts._totalWriteBufferSize ;
@@ -2468,6 +2469,10 @@ void RocksDBEngine::getStatistics(VPackBuilder& builder) const {
2468
2469
builder.add (" rocksdbengine.throttle.bps" , VPackValue (_listener->GetThrottle ()));
2469
2470
} // if
2470
2471
2472
+ if (_errorListener) {
2473
+ builder.add (" rocksdb.read-only" , VPackValue (_errorListener->called () ? 1 : 0 ));
2474
+ }
2475
+
2471
2476
builder.close ();
2472
2477
}
2473
2478
Original file line number Diff line number Diff line change @@ -52,6 +52,7 @@ namespace arangodb {
52
52
53
53
class PhysicalCollection ;
54
54
class PhysicalView ;
55
+ class RocksDBBackgroundErrorListener ;
55
56
class RocksDBBackgroundThread ;
56
57
class RocksDBEventListener ;
57
58
class RocksDBKey ;
@@ -497,6 +498,8 @@ class RocksDBEngine final : public StorageEngine {
497
498
// optional code to notice when rocksdb creates or deletes .ssh files. Currently
498
499
// uses that input to create or delete parallel sha256 files
499
500
std::shared_ptr<RocksDBEventListener> _shaListener;
501
+
502
+ std::shared_ptr<RocksDBBackgroundErrorListener> _errorListener;
500
503
501
504
arangodb::basics::ReadWriteLock _purgeLock;
502
505
You can’t perform that action at this time.
0 commit comments