Forbid write queries on a replica (#80)
Co-authored-by: jseljan <josip.seljan@memgraph.io>
This commit is contained in:
parent
e866526c7a
commit
46b1783618
@ -1661,6 +1661,16 @@ Interpreter::PrepareResult Interpreter::Prepare(
|
|||||||
query_execution->prepared_query->rw_type)
|
query_execution->prepared_query->rw_type)
|
||||||
: "rw";
|
: "rw";
|
||||||
|
|
||||||
|
#ifdef MG_ENTERPRISE
|
||||||
|
if (const auto query_type = query_execution->prepared_query->rw_type;
|
||||||
|
interpreter_context_->db->GetReplicationRole() ==
|
||||||
|
storage::ReplicationRole::REPLICA &&
|
||||||
|
(query_type == RWType::W || query_type == RWType::RW)) {
|
||||||
|
query_execution = nullptr;
|
||||||
|
throw QueryException("Write query forbidden on the replica!");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return {query_execution->prepared_query->header,
|
return {query_execution->prepared_query->header,
|
||||||
query_execution->prepared_query->privileges, qid};
|
query_execution->prepared_query->privileges, qid};
|
||||||
} catch (const utils::BasicException &) {
|
} catch (const utils::BasicException &) {
|
||||||
|
Loading…
Reference in New Issue
Block a user