Skip to content

Commit e3c9dc1

Browse files
committed
Drop support for cursors
1 parent 0e19194 commit e3c9dc1

16 files changed

+28
-527
lines changed

docs/quick-reference.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ You have some control over which peers you're connected to:
6161

6262
### Maintenance
6363

64-
Core keeps old meta around for Horizon and other systems. As cursors get updated, automatic
65-
maintenance normally deletes more than enough for the node to use a constant amount of disk space.
64+
Core keeps historical data needed for publish (such as SCP history)
6665

6766
Sometimes you need to clean up more than this (for example, if you have a large maintenance debt).
6867
In this case running the command `maintenance?count=100000000` (integer is a large number, bigger than your max backlog) will perform the full maintenance.

docs/software/commands.md

-22
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,6 @@ Most commands return their results in JSON format.
244244
`connect?peer=NAME&port=NNN`<br>
245245
Triggers the instance to connect to peer NAME at port NNN.
246246

247-
* **dropcursor**
248-
`dropcursor?id=ID`<br>
249-
Deletes the tracking cursor identified by `id`. See `setcursor` for
250-
more information.
251-
252247
* **droppeer**
253248
`droppeer?node=NODE_ID[&ban=D]`<br>
254249
Drops peer identified by NODE_ID, when D is 1 the peer is also banned.
@@ -307,23 +302,6 @@ Most commands return their results in JSON format.
307302
* `delayed`: participating in the latest consensus rounds, but slower than others.
308303
* `agree`: running just fine.
309304

310-
* **setcursor**
311-
`setcursor?id=ID&cursor=N`<br>
312-
Sets or creates a cursor identified by `ID` with value `N`. ID is an
313-
uppercase AlphaNum, N is an uint32 that represents the last ledger sequence
314-
number that the instance ID processed. Cursors are used by dependent services
315-
to tell stellar-core which data can be safely deleted by the instance. The
316-
data is historical data stored in the SQL tables such as txhistory or
317-
ledgerheaders. When all consumers processed the data for ledger sequence N
318-
the data can be safely removed by the instance. The actual deletion is
319-
performed by invoking the `maintenance` endpoint or on startup. See also
320-
`dropcursor`.
321-
322-
* **getcursor**
323-
`getcursor?[id=ID]`<br>
324-
Gets the cursor identified by `ID`. If ID is not defined then all cursors
325-
will be returned.
326-
327305
* **scp**
328306
`scp?[limit=n][&fullkeys=false]`<br>
329307
Returns a JSON object with the internal state of the SCP engine for the last

docs/stellar-core_example.cfg

-4
Original file line numberDiff line numberDiff line change
@@ -304,10 +304,6 @@ KNOWN_PEERS=[
304304
"core-testnet2.stellar.org",
305305
"core-testnet3.stellar.org"]
306306

307-
# KNOWN_CURSORS (list of strings) default is empty
308-
# Set of cursors added at each startup with value '1'.
309-
KNOWN_CURSORS=["HORIZON"]
310-
311307
#######################
312308
## SCP settings
313309

src/bucket/test/BucketManagerTests.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include "lib/catch.hpp"
2323
#include "main/Application.h"
2424
#include "main/Config.h"
25-
#include "main/ExternalQueue.h"
25+
#include "main/Maintainer.h"
2626
#include "test/TestUtils.h"
2727
#include "test/test.h"
2828
#include "util/GlobalChecks.h"
@@ -641,8 +641,7 @@ TEST_CASE_VERSIONS(
641641
clock.crank(false);
642642

643643
// Trim history after publishing whenever possible.
644-
ExternalQueue ps(*app);
645-
ps.deleteOldEntries(50000);
644+
app->getMaintainer().performMaintenance(50000);
646645
}
647646
});
648647
}

src/database/Database.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#include "history/HistoryManager.h"
2525
#include "ledger/LedgerHeaderUtils.h"
2626
#include "ledger/LedgerTxn.h"
27-
#include "main/ExternalQueue.h"
2827
#include "main/PersistentState.h"
2928
#include "overlay/BanManager.h"
3029
#include "overlay/OverlayManager.h"
@@ -63,7 +62,7 @@ bool Database::gDriversRegistered = false;
6362

6463
// smallest schema version supported
6564
static unsigned long const MIN_SCHEMA_VERSION = 21;
66-
static unsigned long const SCHEMA_VERSION = 23;
65+
static unsigned long const SCHEMA_VERSION = 24;
6766

6867
// These should always match our compiled version precisely, since we are
6968
// using a bundled version to get access to carray(). But in case someone
@@ -219,6 +218,9 @@ Database::applySchemaUpgrade(unsigned long vers)
219218
mApp.getHistoryManager().dropSQLBasedPublish();
220219
Upgrades::dropSupportUpgradeHistory(*this);
221220
break;
221+
case 24:
222+
getSession() << "DROP TABLE IF EXISTS pubsub;";
223+
break;
222224
default:
223225
throw std::runtime_error("Unknown DB schema version");
224226
}
@@ -473,7 +475,6 @@ Database::initialize()
473475
Upgrades::dropAll(*this);
474476
OverlayManager::dropAll(*this);
475477
PersistentState::dropAll(*this);
476-
ExternalQueue::dropAll(*this);
477478
LedgerHeaderUtils::dropAll(*this);
478479
// No need to re-create txhistory, will be dropped during
479480
// upgradeToCurrentSchema anyway

src/herder/test/HerderTests.cpp

-48
Original file line numberDiff line numberDiff line change
@@ -212,54 +212,6 @@ TEST_CASE_VERSIONS("standalone", "[herder][acceptance]")
212212
REQUIRE(c1.loadSequenceNumber() == expectedC1Seq);
213213
}
214214
}
215-
216-
SECTION("Queue processing test")
217-
{
218-
app->getCommandHandler().manualCmd("maintenance?queue=true");
219-
220-
while (app->getLedgerManager().getLastClosedLedgerNum() <
221-
(app->getHistoryManager().getCheckpointFrequency() + 5))
222-
{
223-
app->getClock().crank(true);
224-
}
225-
226-
app->getCommandHandler().manualCmd("setcursor?id=A1&cursor=1");
227-
app->getCommandHandler().manualCmd("maintenance?queue=true");
228-
auto& db = app->getDatabase();
229-
auto& sess = db.getSession();
230-
231-
app->getCommandHandler().manualCmd("setcursor?id=A2&cursor=3");
232-
app->getCommandHandler().manualCmd("maintenance?queue=true");
233-
auto lh = LedgerHeaderUtils::loadBySequence(db, sess, 2);
234-
REQUIRE(!!lh);
235-
236-
app->getCommandHandler().manualCmd("setcursor?id=A1&cursor=2");
237-
// this should delete items older than sequence 2
238-
app->getCommandHandler().manualCmd("maintenance?queue=true");
239-
lh = LedgerHeaderUtils::loadBySequence(db, sess, 2);
240-
REQUIRE(!lh);
241-
lh = LedgerHeaderUtils::loadBySequence(db, sess, 3);
242-
REQUIRE(!!lh);
243-
244-
// this should delete items older than sequence 3
245-
SECTION("set min to 3 by update")
246-
{
247-
app->getCommandHandler().manualCmd(
248-
"setcursor?id=A1&cursor=3");
249-
app->getCommandHandler().manualCmd(
250-
"maintenance?queue=true");
251-
lh = LedgerHeaderUtils::loadBySequence(db, sess, 3);
252-
REQUIRE(!lh);
253-
}
254-
SECTION("set min to 3 by deletion")
255-
{
256-
app->getCommandHandler().manualCmd("dropcursor?id=A1");
257-
app->getCommandHandler().manualCmd(
258-
"maintenance?queue=true");
259-
lh = LedgerHeaderUtils::loadBySequence(db, sess, 3);
260-
REQUIRE(!lh);
261-
}
262-
}
263215
}
264216
});
265217
}

src/history/test/HistoryTests.cpp

+3-5
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#include "historywork/GzipFileWork.h"
1717
#include "historywork/PutHistoryArchiveStateWork.h"
1818
#include "ledger/LedgerManager.h"
19-
#include "main/ExternalQueue.h"
19+
#include "main/Maintainer.h"
2020
#include "main/PersistentState.h"
2121
#include "process/ProcessManager.h"
2222
#include "test/TestAccount.h"
@@ -1375,8 +1375,7 @@ TEST_CASE("persist publish queue", "[history][publish][acceptance]")
13751375
REQUIRE(hm0.getMinLedgerQueuedToPublish() == 7);
13761376

13771377
// Trim history after publishing.
1378-
ExternalQueue ps(*app0);
1379-
ps.deleteOldEntries(50000);
1378+
app0->getMaintainer().performMaintenance(50000);
13801379
}
13811380

13821381
cfg.MAX_CONCURRENT_SUBPROCESSES = 32;
@@ -1395,8 +1394,7 @@ TEST_CASE("persist publish queue", "[history][publish][acceptance]")
13951394
clock.crank(true);
13961395

13971396
// Trim history after publishing whenever possible.
1398-
ExternalQueue ps(*app1);
1399-
ps.deleteOldEntries(50000);
1397+
app1->getMaintainer().performMaintenance(50000);
14001398
}
14011399
// We should have either an empty publish queue or a
14021400
// ledger sometime after the 5th checkpoint

src/main/ApplicationImpl.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
#include "main/AppConnector.h"
3939
#include "main/ApplicationUtils.h"
4040
#include "main/CommandHandler.h"
41-
#include "main/ExternalQueue.h"
4241
#include "main/Maintainer.h"
4342
#include "main/StellarCoreVersion.h"
4443
#include "medida/counter.h"
@@ -872,9 +871,6 @@ ApplicationImpl::startServices()
872871
{
873872
// restores Herder's state before starting overlay
874873
mHerder->start();
875-
// set known cursors before starting maintenance job
876-
ExternalQueue ps(*this);
877-
ps.setInitialCursors(mConfig.KNOWN_CURSORS);
878874
mMaintainer->start();
879875
if (mConfig.MODE_AUTO_STARTS_OVERLAY)
880876
{

src/main/CommandHandler.cpp

-76
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@
3636
#include "xdr/Stellar-transaction.h"
3737
#include "xdrpp/marshal.h"
3838

39-
#include "ExternalQueue.h"
40-
4139
#ifdef BUILD_TESTS
4240
#include "simulation/LoadGenerator.h"
4341
#include "test/TestAccount.h"
@@ -90,9 +88,6 @@ CommandHandler::CommandHandler(Application& app) : mApp(app)
9088
mServer->add404(std::bind(&CommandHandler::fileNotFound, this, _1, _2));
9189
if (mApp.getConfig().modeStoresAnyHistory())
9290
{
93-
addRoute("dropcursor", &CommandHandler::dropcursor);
94-
addRoute("getcursor", &CommandHandler::getcursor);
95-
addRoute("setcursor", &CommandHandler::setcursor);
9691
addRoute("maintenance", &CommandHandler::maintenance);
9792
}
9893

@@ -1011,77 +1006,6 @@ CommandHandler::tx(std::string const& params, std::string& retStr)
10111006
retStr = Json::FastWriter().write(root);
10121007
}
10131008

1014-
void
1015-
CommandHandler::dropcursor(std::string const& params, std::string& retStr)
1016-
{
1017-
ZoneScoped;
1018-
std::map<std::string, std::string> map;
1019-
http::server::server::parseParams(params, map);
1020-
std::string const& id = map["id"];
1021-
1022-
if (!ExternalQueue::validateResourceID(id))
1023-
{
1024-
retStr = "Invalid resource id";
1025-
}
1026-
else
1027-
{
1028-
ExternalQueue ps(mApp);
1029-
ps.deleteCursor(id);
1030-
retStr = "Done";
1031-
}
1032-
}
1033-
1034-
void
1035-
CommandHandler::setcursor(std::string const& params, std::string& retStr)
1036-
{
1037-
ZoneScoped;
1038-
std::map<std::string, std::string> map;
1039-
http::server::server::parseParams(params, map);
1040-
std::string const& id = map["id"];
1041-
1042-
uint32 cursor = parseRequiredParam<uint32>(map, "cursor");
1043-
1044-
if (!ExternalQueue::validateResourceID(id))
1045-
{
1046-
retStr = "Invalid resource id";
1047-
}
1048-
else
1049-
{
1050-
ExternalQueue ps(mApp);
1051-
ps.setCursorForResource(id, cursor);
1052-
retStr = "Done";
1053-
}
1054-
}
1055-
1056-
void
1057-
CommandHandler::getcursor(std::string const& params, std::string& retStr)
1058-
{
1059-
ZoneScoped;
1060-
Json::Value root;
1061-
std::map<std::string, std::string> map;
1062-
http::server::server::parseParams(params, map);
1063-
std::string const& id = map["id"];
1064-
1065-
// the decision was made not to check validity here
1066-
// because there are subsequent checks for that in
1067-
// ExternalQueue and if an exception is thrown for
1068-
// validity there, the ret format is technically more
1069-
// correct for the mime type
1070-
ExternalQueue ps(mApp);
1071-
std::map<std::string, uint32> curMap;
1072-
int counter = 0;
1073-
ps.getCursorForResource(id, curMap);
1074-
root["cursors"][0];
1075-
for (auto cursor : curMap)
1076-
{
1077-
root["cursors"][counter]["id"] = cursor.first;
1078-
root["cursors"][counter]["cursor"] = cursor.second;
1079-
counter++;
1080-
}
1081-
1082-
retStr = root.toStyledString();
1083-
}
1084-
10851009
void
10861010
CommandHandler::maintenance(std::string const& params, std::string& retStr)
10871011
{

src/main/CommandHandler.h

-3
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ class CommandHandler
4949

5050
void bans(std::string const& params, std::string& retStr);
5151
void connect(std::string const& params, std::string& retStr);
52-
void dropcursor(std::string const& params, std::string& retStr);
5352
void dropPeer(std::string const& params, std::string& retStr);
5453
void info(std::string const& params, std::string& retStr);
5554
void ll(std::string const& params, std::string& retStr);
@@ -61,8 +60,6 @@ class CommandHandler
6160
void peers(std::string const& params, std::string& retStr);
6261
void selfCheck(std::string const&, std::string& retStr);
6362
void quorum(std::string const& params, std::string& retStr);
64-
void setcursor(std::string const& params, std::string& retStr);
65-
void getcursor(std::string const& params, std::string& retStr);
6663
void scpInfo(std::string const& params, std::string& retStr);
6764
void tx(std::string const& params, std::string& retStr);
6865
void unban(std::string const& params, std::string& retStr);

src/main/Config.cpp

-13
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#include "herder/Herder.h"
99
#include "history/HistoryArchive.h"
1010
#include "ledger/LedgerManager.h"
11-
#include "main/ExternalQueue.h"
1211
#include "main/StellarCoreVersion.h"
1312
#include "scp/LocalNode.h"
1413
#include "scp/QuorumSetUtils.h"
@@ -1127,18 +1126,6 @@ Config::processConfig(std::shared_ptr<cpptoml::table> t)
11271126
[&]() { BUCKETLIST_DB_PERSIST_INDEX = readBool(item); }},
11281127
{"METADATA_DEBUG_LEDGERS",
11291128
[&]() { METADATA_DEBUG_LEDGERS = readInt<uint32_t>(item); }},
1130-
{"KNOWN_CURSORS",
1131-
[&]() {
1132-
KNOWN_CURSORS = readArray<std::string>(item);
1133-
for (auto const& c : KNOWN_CURSORS)
1134-
{
1135-
if (!ExternalQueue::validateResourceID(c))
1136-
{
1137-
throw std::invalid_argument(fmt::format(
1138-
FMT_STRING("invalid cursor: \"{}\""), c));
1139-
}
1140-
}
1141-
}},
11421129
{"RUN_STANDALONE", [&]() { RUN_STANDALONE = readBool(item); }},
11431130
{"CATCHUP_COMPLETE",
11441131
[&]() { CATCHUP_COMPLETE = readBool(item); }},

src/main/Config.h

-3
Original file line numberDiff line numberDiff line change
@@ -554,9 +554,6 @@ class Config : public std::enable_shared_from_this<Config>
554554
// at a premium.
555555
uint32_t METADATA_DEBUG_LEDGERS;
556556

557-
// Set of cursors added at each startup with value '1'.
558-
std::vector<std::string> KNOWN_CURSORS;
559-
560557
// maximum protocol version supported by the application, can be overridden
561558
// in tests
562559
uint32_t LEDGER_PROTOCOL_VERSION;

0 commit comments

Comments
 (0)