Skip to content

Commit

Permalink
Fix issues with bulk keys removal
Browse files Browse the repository at this point in the history
  • Loading branch information
uglide committed Aug 7, 2020
1 parent 9aace2a commit 91e417b
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 16 deletions.
2 changes: 1 addition & 1 deletion 3rdparty/qredisclient
44 changes: 30 additions & 14 deletions src/app/models/treeoperations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,32 +221,48 @@ void TreeOperations::deleteDbKey(ConnectionsTree::KeyItem& key,
[this, &key](RedisClient::Response) {
key.setRemoved();
QRegExp filter(key.getFullPath(), Qt::CaseSensitive, QRegExp::Wildcard);
emit m_events->closeDbKeys(m_connection, key.getDbIndex(), filter);
if (m_events) m_events->closeDbKeys(m_connection, key.getDbIndex(), filter);
},
[this, callback](const QString& err) {
QString errorMsg =
QCoreApplication::translate("RDM", "Delete key error: %1").arg(err);
callback(errorMsg);
m_events->error(errorMsg);
if (m_events) m_events->error(errorMsg);
});
}

void TreeOperations::deleteDbKeys(ConnectionsTree::DatabaseItem& db) {
requestBulkOperation(db, BulkOperations::Manager::Operation::DELETE_KEYS,
[this, &db](QRegExp filter, int, const QStringList&) {
db.reload();
emit m_events->closeDbKeys(m_connection,
db.getDbIndex(), filter);
});
auto self = sharedFromThis().toWeakRef();
requestBulkOperation(
db, BulkOperations::Manager::Operation::DELETE_KEYS,
[self, this, &db](QRegExp filter, int, const QStringList&) {
if (!self) {
return;
}

db.reload();

if (m_events) {
emit m_events->closeDbKeys(m_connection, db.getDbIndex(), filter);
}
});
}

void TreeOperations::deleteDbNamespace(ConnectionsTree::NamespaceItem& ns) {
requestBulkOperation(ns, BulkOperations::Manager::Operation::DELETE_KEYS,
[this, &ns](QRegExp filter, int, const QStringList&) {
ns.setRemoved();
emit m_events->closeDbKeys(m_connection,
ns.getDbIndex(), filter);
});
auto self = sharedFromThis().toWeakRef();
requestBulkOperation(
ns, BulkOperations::Manager::Operation::DELETE_KEYS,
[this, self, &ns](QRegExp filter, int, const QStringList&) {
if (!self) {
return;
}

ns.setRemoved();

if (m_events) {
emit m_events->closeDbKeys(m_connection, ns.getDbIndex(), filter);
}
});
}

void TreeOperations::setTTL(ConnectionsTree::AbstractNamespaceItem& ns) {
Expand Down
6 changes: 5 additions & 1 deletion src/modules/bulk-operations/operations/deleteoperation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,17 @@ void BulkOperations::DeleteOperation::deleteKeys(
int expectedResponses = rawCmds.size();

m_connection->pipelinedCmd(
rawCmds, this, -1,
rawCmds, this, m_dbIndex,
[this, expectedResponses, callback](const RedisClient::Response &r,
QString err) {
if (!err.isEmpty()) {
return processError(err);
}

if (r.isErrorMessage()) {
return processError(r.value().toByteArray());
}

QMutexLocker l(&m_processedKeysMutex);
QVariant incrResult = r.value();

Expand Down

0 comments on commit 91e417b

Please sign in to comment.