Commit 227f0fc9 authored by jan.koester's avatar jan.koester
Browse files

test

parent ba2b58d8
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -111,6 +111,7 @@ private:

    bool scan_and_build_index();
    void maybe_auto_vacuum();
    bool vacuum_impl(); // internal vacuum, caller must hold mutex_
};

// QUIC-based parity storage server
+3 −0
Original line number Diff line number Diff line
@@ -334,7 +334,10 @@ void client::store_stripe(uint64_t group_id, uint32_t stripe_index,

        if (static_cast<int>(i) == local_node_index_ && local_store_) {
            pending[i].local = true;
            std::cerr << "[PARITY] send_to_node[" << i << "]: local store gid=" << group_id
                      << " bidx=" << block_index << " blen=" << blen << std::endl;
            pending[i].ok = local_store_->store(group_id, block_index, bdata, blen);
            std::cerr << "[PARITY] send_to_node[" << i << "]: local store result=" << pending[i].ok << std::endl;
            if (!pending[i].ok) pending[i].fail_reason = "local store failed";
            pending[i].sent = true;
            return;
+6 −1
Original line number Diff line number Diff line
@@ -297,7 +297,11 @@ std::vector<uint64_t> file_block_store::list_groups() {

bool file_block_store::vacuum() {
    std::lock_guard<std::mutex> lock(mutex_);
    return vacuum_impl();
}

bool file_block_store::vacuum_impl() {
    // Must be called with mutex_ held
    std::string tmp_path = data_path_ + ".tmp";
    int tmp_fd = pp_open(tmp_path.c_str(), O_RDWR | O_CREAT | O_TRUNC, 0644);
    if (tmp_fd < 0) return false;
@@ -355,10 +359,11 @@ bool file_block_store::vacuum() {

void file_block_store::maybe_auto_vacuum() {
    // Auto-vacuum when dead space exceeds 10MB and is more than 50% of the file
    // NOTE: caller already holds mutex_, so call vacuum_impl() directly
    static constexpr off_t MIN_DEAD_BYTES = 10 * 1024 * 1024; // 10 MB
    if (dead_bytes_ >= MIN_DEAD_BYTES && file_size_ > 0 &&
        dead_bytes_ > file_size_ / 2) {
        vacuum();
        vacuum_impl();
    }
}