1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-08-05 16:15:50 +03:00

MCOL-3563: remove the dumb errorHandle test. Misread what this was doing. described the connection test behavior.

This commit is contained in:
benthompson15
2019-11-22 18:36:53 -06:00
parent 3565d237ed
commit a0ffc427ec

View File

@@ -190,7 +190,7 @@ void makeConnection()
t.join(); t.join();
} }
bool opentask(bool connectionTest=false, bool errorHandle=false) bool opentask(bool connectionTest=false)
{ {
// going to rely on msgs being smaller than the buffer here // going to rely on msgs being smaller than the buffer here
int err=0; int err=0;
@@ -211,22 +211,28 @@ bool opentask(bool connectionTest=false, bool errorHandle=false)
cout << "open file " << filename << endl; cout << "open file " << filename << endl;
::unlink(filename); ::unlink(filename);
// set payload to be shorter than actual message lengh
// and send a shortened message.
if (connectionTest) if (connectionTest)
hdr->payloadLen -= 2; hdr->payloadLen -= 2;
size_t result = ::write(sessionSock, cmd, hdr->payloadLen); size_t result = ::write(sessionSock, cmd, hdr->payloadLen);
assert(result==(hdr->payloadLen)); assert(result==(hdr->payloadLen));
if (errorHandle) // set payload to be correct length again
clientSock = 9999999;
if (connectionTest) if (connectionTest)
hdr->payloadLen += 2; hdr->payloadLen += 2;
// process task will look for the full length and
// will wait on the rest of the message.
ProcessTask pt(clientSock, hdr->payloadLen); ProcessTask pt(clientSock, hdr->payloadLen);
boost::thread t(pt); boost::thread t(pt);
if (connectionTest) if (connectionTest)
{ {
// make sure the thread is waiting for the rest of the data
// then kill the connection. This will trigger the task thread
// to exit on an error handling path
sleep(1); sleep(1);
close(sessionSock); close(sessionSock);
close(clientSock); close(clientSock);
@@ -234,12 +240,6 @@ bool opentask(bool connectionTest=false, bool errorHandle=false)
assert(err == -1); assert(err == -1);
t.join(); t.join();
} }
else if (errorHandle)
{
err = ::recv(sessionSock, buf, 1024, MSG_DONTWAIT);
assert(err == -1);
t.join();
}
else else
{ {
t.join(); t.join();
@@ -507,7 +507,7 @@ bool appendtask()
return true; return true;
} }
void unlinktask(bool connectionTest=false, bool errorHandle=false) void unlinktask(bool connectionTest=false)
{ {
int err=0; int err=0;
// make a meta file and delete it // make a meta file and delete it
@@ -532,22 +532,28 @@ void unlinktask(bool connectionTest=false, bool errorHandle=false)
cmd->flen = strlen(filename); cmd->flen = strlen(filename);
memcpy(&cmd->filename, filename, cmd->flen); memcpy(&cmd->filename, filename, cmd->flen);
// set payload to be shorter than actual message lengh
// and send a shortened message.
if (connectionTest) if (connectionTest)
cmd->flen -= 2; cmd->flen -= 2;
size_t result = ::write(sessionSock, cmd, sizeof(unlink_cmd) + cmd->flen); size_t result = ::write(sessionSock, cmd, sizeof(unlink_cmd) + cmd->flen);
assert(result==(sizeof(unlink_cmd) + cmd->flen)); assert(result==(sizeof(unlink_cmd) + cmd->flen));
if (errorHandle) // set payload to be correct length again
clientSock = 9999999;
if (connectionTest) if (connectionTest)
cmd->flen += 2; cmd->flen += 2;
// process task will look for the full length and
// will wait on the rest of the message.
ProcessTask pt(clientSock, sizeof(unlink_cmd) + cmd->flen); ProcessTask pt(clientSock, sizeof(unlink_cmd) + cmd->flen);
boost::thread t(pt); boost::thread t(pt);
if (connectionTest) if (connectionTest)
{ {
// make sure the thread is waiting for the rest of the data
// then kill the connection. This will trigger the task thread
// to exit on an error handling path
sleep(1); sleep(1);
close(sessionSock); close(sessionSock);
close(clientSock); close(clientSock);
@@ -555,12 +561,6 @@ void unlinktask(bool connectionTest=false, bool errorHandle=false)
assert(err == -1); assert(err == -1);
t.join(); t.join();
} }
else if (errorHandle)
{
err = ::recv(sessionSock, buf, 1024, MSG_DONTWAIT);
assert(err == -1);
t.join();
}
else else
{ {
t.join(); t.join();
@@ -608,7 +608,7 @@ void unlinktask(bool connectionTest=false, bool errorHandle=false)
cout << "unlink task OK" << endl; cout << "unlink task OK" << endl;
} }
bool stattask(bool connectionTest=false, bool errorHandle=false) bool stattask(bool connectionTest=false)
{ {
int err=0; int err=0;
bf::path fullPath = homepath / prefix / "stattest1"; bf::path fullPath = homepath / prefix / "stattest1";
@@ -627,23 +627,28 @@ bool stattask(bool connectionTest=false, bool errorHandle=false)
cmd->flen = filename.length(); cmd->flen = filename.length();
strcpy((char *) cmd->filename, filename.c_str()); strcpy((char *) cmd->filename, filename.c_str());
// set payload to be shorter than actual message lengh
// and send a shortened message.
if (connectionTest) if (connectionTest)
cmd->flen -= 2; cmd->flen -= 2;
size_t result = ::write(sessionSock, cmd, sizeof(*cmd) + cmd->flen); size_t result = ::write(sessionSock, cmd, sizeof(*cmd) + cmd->flen);
assert(result==(sizeof(*cmd) + cmd->flen)); assert(result==(sizeof(*cmd) + cmd->flen));
// set payload to be correct length again
if (errorHandle)
clientSock = 9999999;
if (connectionTest) if (connectionTest)
cmd->flen += 2; cmd->flen += 2;
// process task will look for the full length and
// will wait on the rest of the message.
ProcessTask pt(clientSock, sizeof(*cmd) + cmd->flen); ProcessTask pt(clientSock, sizeof(*cmd) + cmd->flen);
boost::thread t(pt); boost::thread t(pt);
if (connectionTest) if (connectionTest)
{ {
// make sure the thread is waiting for the rest of the data
// then kill the connection. This will trigger the task thread
// to exit on an error handling path
sleep(1); sleep(1);
close(sessionSock); close(sessionSock);
close(clientSock); close(clientSock);
@@ -651,12 +656,6 @@ bool stattask(bool connectionTest=false, bool errorHandle=false)
assert(err == -1); assert(err == -1);
t.join(); t.join();
} }
else if (errorHandle)
{
err = ::recv(sessionSock, buf, 1024, MSG_DONTWAIT);
assert(err == -1);
t.join();
}
else else
{ {
t.join(); t.join();
@@ -822,7 +821,7 @@ bool IOCTruncate()
} }
bool truncatetask(bool connectionTest=false, bool errorHandle=false) bool truncatetask(bool connectionTest=false)
{ {
IOCoordinator *ioc = IOCoordinator::get(); IOCoordinator *ioc = IOCoordinator::get();
Cache *cache = Cache::get(); Cache *cache = Cache::get();
@@ -846,22 +845,28 @@ bool truncatetask(bool connectionTest=false, bool errorHandle=false)
cmd->flen = strlen(filename); cmd->flen = strlen(filename);
strcpy((char *) cmd->filename, filename); strcpy((char *) cmd->filename, filename);
// set payload to be shorter than actual message lengh
// and send a shortened message.
if (connectionTest) if (connectionTest)
cmd->flen -= 2; cmd->flen -= 2;
size_t result = ::write(sessionSock, cmd, sizeof(*cmd) + cmd->flen); size_t result = ::write(sessionSock, cmd, sizeof(*cmd) + cmd->flen);
assert(result==(sizeof(*cmd) + cmd->flen)); assert(result==(sizeof(*cmd) + cmd->flen));
if (errorHandle) // set payload to be correct length again
clientSock = 9999999;
if (connectionTest) if (connectionTest)
cmd->flen += 2; cmd->flen += 2;
// process task will look for the full length and
// will wait on the rest of the message.
ProcessTask pt(clientSock, sizeof(*cmd) + cmd->flen); ProcessTask pt(clientSock, sizeof(*cmd) + cmd->flen);
boost::thread t(pt); boost::thread t(pt);
if (connectionTest) if (connectionTest)
{ {
// make sure the thread is waiting for the rest of the data
// then kill the connection. This will trigger the task thread
// to exit on an error handling path
sleep(1); sleep(1);
close(sessionSock); close(sessionSock);
close(clientSock); close(clientSock);
@@ -869,12 +874,6 @@ bool truncatetask(bool connectionTest=false, bool errorHandle=false)
assert(err == -1); assert(err == -1);
t.join(); t.join();
} }
else if (errorHandle)
{
err = ::recv(sessionSock, buf, 1024, MSG_DONTWAIT);
assert(err == -1);
t.join();
}
else else
{ {
t.join(); t.join();
@@ -897,7 +896,7 @@ bool truncatetask(bool connectionTest=false, bool errorHandle=false)
return true; return true;
} }
bool listdirtask(bool connectionTest=false,bool errorHandle=false) bool listdirtask(bool connectionTest=false)
{ {
IOCoordinator *ioc = IOCoordinator::get(); IOCoordinator *ioc = IOCoordinator::get();
const bf::path metaPath = ioc->getMetadataPath(); const bf::path metaPath = ioc->getMetadataPath();
@@ -932,23 +931,28 @@ bool listdirtask(bool connectionTest=false,bool errorHandle=false)
cmd->plen = strlen(relPath); cmd->plen = strlen(relPath);
memcpy(cmd->path, relPath, cmd->plen); memcpy(cmd->path, relPath, cmd->plen);
// set payload to be shorter than actual message lengh
// and send a shortened message.
if (connectionTest) if (connectionTest)
cmd->plen -= 2; cmd->plen -= 2;
size_t result = ::write(sessionSock, cmd, sizeof(*cmd) + cmd->plen); size_t result = ::write(sessionSock, cmd, sizeof(*cmd) + cmd->plen);
assert(result==(sizeof(*cmd) + cmd->plen)); assert(result==(sizeof(*cmd) + cmd->plen));
if (errorHandle) // set payload to be correct length again
clientSock = 9999999;
if (connectionTest) if (connectionTest)
cmd->plen += 2; cmd->plen += 2;
//ListDirectoryTask l(clientSock, sizeof(*cmd) + cmd->plen);
//l.run(); // process task will look for the full length and
// will wait on the rest of the message.
ProcessTask pt(clientSock, sizeof(*cmd) + cmd->plen); ProcessTask pt(clientSock, sizeof(*cmd) + cmd->plen);
boost::thread t(pt); boost::thread t(pt);
if (connectionTest) if (connectionTest)
{ {
// make sure the thread is waiting for the rest of the data
// then kill the connection. This will trigger the task thread
// to exit on an error handling path
sleep(1); sleep(1);
close(sessionSock); close(sessionSock);
close(clientSock); close(clientSock);
@@ -956,12 +960,6 @@ bool listdirtask(bool connectionTest=false,bool errorHandle=false)
assert(err == -1); assert(err == -1);
t.join(); t.join();
} }
else if (errorHandle)
{
err = ::recv(sessionSock, buf, 8192, MSG_DONTWAIT);
assert(err == -1);
t.join();
}
else else
{ {
t.join(); t.join();
@@ -998,7 +996,7 @@ bool listdirtask(bool connectionTest=false,bool errorHandle=false)
return true; return true;
} }
void pingtask(bool connectionTest=false, bool errorHandle=false) void pingtask(bool connectionTest=false)
{ {
int err=0; int err=0;
uint8_t buf[1024]; uint8_t buf[1024];
@@ -1007,22 +1005,28 @@ void pingtask(bool connectionTest=false, bool errorHandle=false)
size_t len = sizeof(*cmd); size_t len = sizeof(*cmd);
// set payload to be shorter than actual message lengh
// and send a shortened message.
if (connectionTest) if (connectionTest)
len -= 2; len -= 2;
ssize_t result = ::write(sessionSock, cmd, sizeof(*cmd)); ssize_t result = ::write(sessionSock, cmd, sizeof(*cmd));
assert(result==(sizeof(*cmd))); assert(result==(sizeof(*cmd)));
if (errorHandle) // set payload to be correct length again
clientSock = 9999999;
if (connectionTest) if (connectionTest)
len += 2; len += 2;
// process task will look for the full length and
// will wait on the rest of the message.
ProcessTask pt(clientSock, len); ProcessTask pt(clientSock, len);
boost::thread t(pt); boost::thread t(pt);
if (connectionTest) if (connectionTest)
{ {
// make sure the thread is waiting for the rest of the data
// then kill the connection. This will trigger the task thread
// to exit on an error handling path
sleep(1); sleep(1);
close(sessionSock); close(sessionSock);
close(clientSock); close(clientSock);
@@ -1030,12 +1034,6 @@ void pingtask(bool connectionTest=false, bool errorHandle=false)
assert(err == -1); assert(err == -1);
t.join(); t.join();
} }
else if (errorHandle)
{
err = ::recv(sessionSock, buf, 1024, MSG_DONTWAIT);
assert(err == -1);
t.join();
}
else else
{ {
t.join(); t.join();
@@ -1052,7 +1050,7 @@ void pingtask(bool connectionTest=false, bool errorHandle=false)
cout << "pingtask OK" << endl; cout << "pingtask OK" << endl;
} }
bool copytask(bool connectionTest=false, bool errorHandle=false) bool copytask(bool connectionTest=false)
{ {
/* /*
make a file make a file
@@ -1083,6 +1081,8 @@ bool copytask(bool connectionTest=false, bool errorHandle=false)
uint len = (uint64_t) &file2->filename[file2->flen] - (uint64_t) buf; uint len = (uint64_t) &file2->filename[file2->flen] - (uint64_t) buf;
// set payload to be shorter than actual message lengh
// and send a shortened message.
if (connectionTest) if (connectionTest)
len -= 2; len -= 2;
@@ -1091,16 +1091,20 @@ bool copytask(bool connectionTest=false, bool errorHandle=false)
int err=0; int err=0;
if (errorHandle) // set payload to be correct length again
clientSock = 9999999;
if (connectionTest) if (connectionTest)
len += 2; len += 2;
// process task will look for the full length and
// will wait on the rest of the message.
ProcessTask pt(clientSock, len); ProcessTask pt(clientSock, len);
boost::thread t(pt); boost::thread t(pt);
if (connectionTest) if (connectionTest)
{ {
// make sure the thread is waiting for the rest of the data
// then kill the connection. This will trigger the task thread
// to exit on an error handling path
sleep(1); sleep(1);
close(sessionSock); close(sessionSock);
close(clientSock); close(clientSock);
@@ -1108,12 +1112,6 @@ bool copytask(bool connectionTest=false, bool errorHandle=false)
assert(err == -1); assert(err == -1);
t.join(); t.join();
} }
else if (errorHandle)
{
err = ::recv(sessionSock, buf, 1024, MSG_DONTWAIT);
assert(err == -1);
t.join();
}
else else
{ {
t.join(); t.join();
@@ -2001,31 +1999,17 @@ int main(int argc, char* argv[])
//opentask(); //opentask();
opentask(true); opentask(true);
makeConnection(); makeConnection();
opentask(false,true);
makeConnection();
unlinktask(true); unlinktask(true);
makeConnection(); makeConnection();
unlinktask(false,true);
makeConnection();
stattask(true); stattask(true);
makeConnection(); makeConnection();
stattask(false,true);
makeConnection();
truncatetask(true); truncatetask(true);
makeConnection(); makeConnection();
truncatetask(false,true);
makeConnection();
listdirtask(true); listdirtask(true);
makeConnection(); makeConnection();
listdirtask(false,true);
makeConnection();
pingtask(true); pingtask(true);
makeConnection(); makeConnection();
pingtask(false,true);
makeConnection();
copytask(true); copytask(true);
makeConnection();
copytask(false,true);
(Cache::get())->shutdown(); (Cache::get())->shutdown();
delete (Synchronizer::get()); delete (Synchronizer::get());