Compare commits
6 Commits
fix_finali
...
add-gc-for
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c77d84ef6d | ||
|
|
186be4c213 | ||
|
|
4e06e769f1 | ||
|
|
311c129bfc | ||
|
|
fe577aab18 | ||
|
|
9a3ce1ef01 |
@@ -154,6 +154,12 @@ inline int &Get_Thread_Tracker() {
|
||||
|
||||
bool QueriesMemoryControl::IsThreadTracked() { return Get_Thread_Tracker() == 1; }
|
||||
|
||||
void QueriesMemoryControl::ResetTrackings() {
|
||||
Get_Thread_Tracker() = 0;
|
||||
transaction_id_to_tracker.clear();
|
||||
thread_id_to_transaction_id.clear();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void StartTrackingCurrentThreadTransaction(uint64_t transaction_id) {
|
||||
@@ -190,6 +196,12 @@ void TryStopTrackingOnTransaction(uint64_t transaction_id) {
|
||||
#endif
|
||||
}
|
||||
|
||||
void CleanTracker() {
|
||||
#if USE_JEMALLOC
|
||||
GetQueriesMemoryControl().ResetTrackings();
|
||||
#endif
|
||||
}
|
||||
|
||||
#if USE_JEMALLOC
|
||||
bool IsTransactionTracked(uint64_t transaction_id) {
|
||||
return GetQueriesMemoryControl().CheckTransactionIdTrackerExists(transaction_id);
|
||||
|
||||
@@ -77,6 +77,12 @@ class QueriesMemoryControl {
|
||||
|
||||
bool IsThreadTracked();
|
||||
|
||||
// This method resets all the trackings.
|
||||
// Method is not thread-safe so it should
|
||||
// be called when there is global lock
|
||||
// to not create new transactions
|
||||
void ResetTrackings();
|
||||
|
||||
private:
|
||||
struct ThreadIdToTransactionId {
|
||||
std::thread::id thread_id;
|
||||
@@ -127,6 +133,11 @@ void TryStartTrackingOnTransaction(uint64_t transaction_id, size_t limit);
|
||||
// Does nothing if jemalloc is not enabled. Does nothing if tracker doesn't exist
|
||||
void TryStopTrackingOnTransaction(uint64_t transaction_id);
|
||||
|
||||
// This method requires lock on global storage
|
||||
// It will clean all trackers which may accidentally have left in system
|
||||
// It will reset any tracking on arenas
|
||||
void CleanTracker();
|
||||
|
||||
// Is transaction with given id tracked in memory tracker
|
||||
bool IsTransactionTracked(uint64_t transaction_id);
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
#include "storage/v2/inmemory/storage.hpp"
|
||||
#include "dbms/constants.hpp"
|
||||
#include "memory/query_memory_control.hpp"
|
||||
#include "memory/global_memory_control.hpp"
|
||||
#include "storage/v2/durability/durability.hpp"
|
||||
#include "storage/v2/durability/snapshot.hpp"
|
||||
@@ -1243,7 +1244,11 @@ void InMemoryStorage::CollectGarbage(std::unique_lock<utils::ResourceLock> main_
|
||||
if (!gc_guard.owns_lock()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if constexpr (force) {
|
||||
if (main_guard.owns_lock()) {
|
||||
memgraph::memory::CleanTracker();
|
||||
}
|
||||
}
|
||||
uint64_t oldest_active_start_timestamp = commit_log_->OldestActive();
|
||||
|
||||
// Deltas from previous GC runs or from aborts can be cleaned up here
|
||||
|
||||
Reference in New Issue
Block a user