DB
plugin to make leaders just refuse writes escalated from permanent followers.
Permafollower
, such as shown here: https://github.com/Expensify/Bedrock/blob/cf2c36027f569df277d3f97ea08ff8a917ad014a/sqlitecluster/SQLiteNode.cpp#L370
DB.cpp
to a new file SecureDB.cpp
in /plugins
-- that'll ensure it just compiles easy. Later when you have proven it out, you'll likely want to move your SecureDB.cpp
plugin into your own private repo, but I'd suggest skipping that to start.
SecureDB
plugin, launch Bedrock with the -plugins SecureDB
parameter to enable it (and notably, don't enable DB
, as that doesn't have the security check you want)
Permafollower
, but it is as simple as making the -priority
of the follower 0
in the follower's command line, and then adding ?Permafollower=true
to the node definition in -peerList
on all of the full nodes. So, like -peerList node1:9001,node2:9002?Permafollower=true
would indicate that node2:9002
is a Permafollower. This is necessary to configure on the leader as well as the follower, because obviously the leader can't trust the follower to advertise its own permafollower status (given that you are using this to identify "untrusted" nodes).
@quinthar Pardon me for asking a trivial question. I tried creating the SecureDB.cpp as suggested that is needed in this logic (I hope I located it in the right location)
if (SStartsWith(upperQuery, "INSERT ")) {
if(peer->params["Permafollower"] == "true") {
STHROW("400 Unauthorized");
} else
response["lastInsertRowID"] = SToStr(db.getLastInsertRowID());
}
... but sadly, am having trouble getting the code to understand "peer" variable
I tried this
Peer* peer = getPeerByID(command.initiatingPeerID);
(and I included some .h files at the top of the code)
This is in the BedrockPlugin_DB::processCommand(...) function but does not compile (that is how I came to know about "peer" variable) .
My C++ is quite rusty and I have not fully gone thru the code -- just kind of intuitively understanding what is to be done.
Hi all, I currently run a Discord bot with a SQLite backend database. It was working fine until I enabled sharding, meaning there are multiple threads writing/reading from the same SQLite database. I've enabled WAL mode however I still get SQLITE_BUSY error codes.
I stumbled upon Bedrock, so I figured I could give it a shot. I was able to build and run Bedrock successfully, pointing to my existing SQLite file, however, because there's no Java SDK for Bedrock I decided to give the MySQL plugin a shot. This is where the horror story starts, I'm only able to make SQL queries by connecting to Bedrock via the MySQL CLI client, but not if I'm connected via my bot using the ORM.
Am I out of luck here?
I hope this channel can help me: I just created Expensify/Bedrock#788
The tests pass and it is running, but it doesn't seem to matter what I send on 8888, I get no response. Any advice?
$ nc localhost 8888
SELECT 1;
Query: SELECT 1;
Query:
SELECT 1;
All with no response
/var/log/syslog
to see if any errors are being output? Also, what is the exact command line you are running?
SLogStackTrace()':
/Bedrock/libstuff/SLog.cpp:10: undefined reference to
backtrace'SGetCallstack[abi:cxx11](int, void* const*)':
/Bedrock/libstuff/libstuff.cpp:107: undefined reference to
backtrace_symbols'SException::SException(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int, bool, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, SString, STableComp, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, SString> > > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
/Bedrock/libstuff/libstuff.cpp:95: undefined reference to
backtrace'_SSignal_StackTrace(int, siginfo_t*, void*)':
/Bedrock/libstuff/SSignal.cpp:151: undefined reference to
backtrace'