ircd:Ⓜ️ Add slave refresh interface.
This commit is contained in:
parent
1973e2c086
commit
fc495f06ef
|
@ -84,6 +84,7 @@ struct ircd::m::homeserver
|
||||||
static homeserver *init(const struct opts *);
|
static homeserver *init(const struct opts *);
|
||||||
static void fini(homeserver *) noexcept;
|
static void fini(homeserver *) noexcept;
|
||||||
static bool rehash(homeserver *);
|
static bool rehash(homeserver *);
|
||||||
|
static bool refresh(homeserver *);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ircd::m::homeserver::key
|
struct ircd::m::homeserver::key
|
||||||
|
|
|
@ -13,6 +13,8 @@
|
||||||
|
|
||||||
namespace ircd::m::vm::sequence
|
namespace ircd::m::vm::sequence
|
||||||
{
|
{
|
||||||
|
struct refresh;
|
||||||
|
|
||||||
extern ctx::dock dock;
|
extern ctx::dock dock;
|
||||||
extern uint64_t retired; // already written; always monotonic
|
extern uint64_t retired; // already written; always monotonic
|
||||||
extern uint64_t committed; // pending write; usually monotonic
|
extern uint64_t committed; // pending write; usually monotonic
|
||||||
|
@ -25,3 +27,12 @@ namespace ircd::m::vm::sequence
|
||||||
uint64_t max();
|
uint64_t max();
|
||||||
uint64_t min();
|
uint64_t min();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct ircd::m::vm::sequence::refresh
|
||||||
|
{
|
||||||
|
uint64_t database[2] {0, 0};
|
||||||
|
uint64_t retired[2] {0, 0};
|
||||||
|
m::event::id::buf event_id;
|
||||||
|
|
||||||
|
refresh();
|
||||||
|
};
|
||||||
|
|
|
@ -227,6 +227,41 @@ ircd::m::homeserver::rehash(homeserver *const homeserver)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
IRCD_MODULE_EXPORT
|
||||||
|
ircd::m::homeserver::refresh(homeserver *const homeserver)
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if(!homeserver)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
const ctx::uninterruptible::nothrow ui;
|
||||||
|
const vm::sequence::refresh refresh;
|
||||||
|
if(ircd::debugmode)
|
||||||
|
log::logf
|
||||||
|
{
|
||||||
|
log, log::level::DEBUG,
|
||||||
|
"refreshed events[%12lu -> %-12lu] vm[%10lu -> %-10lu] %s",
|
||||||
|
refresh.database[0],
|
||||||
|
refresh.database[1],
|
||||||
|
refresh.retired[0],
|
||||||
|
refresh.retired[1],
|
||||||
|
string_view{refresh.event_id},
|
||||||
|
};
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch(const std::exception &e)
|
||||||
|
{
|
||||||
|
log::error
|
||||||
|
{
|
||||||
|
log, "refresh :%s",
|
||||||
|
e.what(),
|
||||||
|
};
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// homeserver::homeserver::homeserver
|
// homeserver::homeserver::homeserver
|
||||||
//
|
//
|
||||||
|
|
|
@ -20,6 +20,34 @@ ircd::m::vm::sequence::committed;
|
||||||
decltype(ircd::m::vm::sequence::uncommitted)
|
decltype(ircd::m::vm::sequence::uncommitted)
|
||||||
ircd::m::vm::sequence::uncommitted;
|
ircd::m::vm::sequence::uncommitted;
|
||||||
|
|
||||||
|
//
|
||||||
|
// refresh::refresh
|
||||||
|
//
|
||||||
|
|
||||||
|
ircd::m::vm::sequence::refresh::refresh()
|
||||||
|
{
|
||||||
|
auto &database
|
||||||
|
{
|
||||||
|
db::database::get("events")
|
||||||
|
};
|
||||||
|
|
||||||
|
if(!database.slave)
|
||||||
|
return;
|
||||||
|
|
||||||
|
this->database[0] = db::sequence(database);
|
||||||
|
this->retired[0] = sequence::retired;
|
||||||
|
|
||||||
|
db::refresh(database);
|
||||||
|
sequence::retired = sequence::get(this->event_id);
|
||||||
|
|
||||||
|
this->database[1] = db::sequence(database);
|
||||||
|
this->retired[1] = sequence::retired;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// tools
|
||||||
|
//
|
||||||
|
|
||||||
uint64_t
|
uint64_t
|
||||||
ircd::m::vm::sequence::min()
|
ircd::m::vm::sequence::min()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue