drogonframework / drogon

Drogon: A C++14/17/20 based HTTP web application framework running on Linux/macOS/Unix/Windows
MIT License
11.52k stars 1.1k forks source link

[Database] Sometimes some columns has null value. #1057

Closed 0rangeFox closed 2 years ago

0rangeFox commented 2 years ago

Well the problem is already described on title. Whenever I start the server, it always returns null, but after spamming some requests it starts to come with values, and after that it sometimes starts to come null or with values, and it's only happening in that column "subscriptionExpiresAt" at the moment.

Logs: ```bash root@:~/webservice/build# make && make install && ./WebService [ 13%] Built target trantor [ 39%] Built target drogon Scanning dependencies of target WebService [ 39%] Building CXX object CMakeFiles/WebService.dir/src/filters/v1/user/UserFilter.cc.o [ 39%] Linking CXX executable WebService [ 57%] Built target WebService [ 58%] Built target client [ 59%] Built target benchmark [ 60%] Built target websocket_client [ 61%] Built target websocket_server [ 64%] Built target _drogon_ctl [ 87%] Built target drogon_ctl [ 88%] Built target file_upload [ 89%] Built target jsonstore [ 92%] Built target login_session [ 95%] Built target helloworld [ 95%] Built target print-claims [ 96%] Built target rsa-verify [ 97%] Built target jwks-verify [ 98%] Built target private-claims [ 99%] Built target es256k [100%] Built target rsa-create [ 13%] Built target trantor [ 39%] Built target drogon [ 57%] Built target WebService [ 58%] Built target client [ 59%] Built target benchmark [ 60%] Built target websocket_client [ 61%] Built target websocket_server [ 64%] Built target _drogon_ctl [ 87%] Built target drogon_ctl [ 88%] Built target file_upload [ 89%] Built target jsonstore [ 92%] Built target login_session [ 95%] Built target helloworld [ 95%] Built target print-claims [ 96%] Built target rsa-verify [ 97%] Built target jwks-verify [ 98%] Built target private-claims [ 99%] Built target es256k [100%] Built target rsa-create Install the project... -- Install configuration: "" -- Up-to-date: /usr/local/lib/libdrogon.a -- Up-to-date: /usr/local/include/drogon/Attribute.h -- Up-to-date: /usr/local/include/drogon/CacheMap.h -- Up-to-date: /usr/local/include/drogon/Cookie.h -- Up-to-date: /usr/local/include/drogon/DrClassMap.h -- Up-to-date: /usr/local/include/drogon/DrObject.h -- Up-to-date: /usr/local/include/drogon/DrTemplate.h -- Up-to-date: /usr/local/include/drogon/DrTemplateBase.h -- Up-to-date: /usr/local/include/drogon/HttpAppFramework.h -- Up-to-date: /usr/local/include/drogon/HttpBinder.h -- Up-to-date: /usr/local/include/drogon/HttpClient.h -- Up-to-date: /usr/local/include/drogon/HttpController.h -- Up-to-date: /usr/local/include/drogon/HttpFilter.h -- Up-to-date: /usr/local/include/drogon/HttpRequest.h -- Up-to-date: /usr/local/include/drogon/HttpResponse.h -- Up-to-date: /usr/local/include/drogon/HttpSimpleController.h -- Up-to-date: /usr/local/include/drogon/HttpTypes.h -- Up-to-date: /usr/local/include/drogon/HttpViewData.h -- Up-to-date: /usr/local/include/drogon/IntranetIpFilter.h -- Up-to-date: /usr/local/include/drogon/IOThreadStorage.h -- Up-to-date: /usr/local/include/drogon/LocalHostFilter.h -- Up-to-date: /usr/local/include/drogon/MultiPart.h -- Up-to-date: /usr/local/include/drogon/NotFound.h -- Up-to-date: /usr/local/include/drogon/Session.h -- Up-to-date: /usr/local/include/drogon/UploadFile.h -- Up-to-date: /usr/local/include/drogon/WebSocketClient.h -- Up-to-date: /usr/local/include/drogon/WebSocketConnection.h -- Up-to-date: /usr/local/include/drogon/WebSocketController.h -- Up-to-date: /usr/local/include/drogon/drogon.h -- Up-to-date: /usr/local/include/drogon/version.h -- Up-to-date: /usr/local/include/drogon/drogon_callbacks.h -- Up-to-date: /usr/local/include/drogon/PubSubService.h -- Up-to-date: /usr/local/include/drogon/drogon_test.h -- Up-to-date: /usr/local/include/drogon/exports.h -- Up-to-date: /usr/local/include/drogon/orm/ArrayParser.h -- Up-to-date: /usr/local/include/drogon/orm/Criteria.h -- Up-to-date: /usr/local/include/drogon/orm/DbClient.h -- Up-to-date: /usr/local/include/drogon/orm/DbTypes.h -- Up-to-date: /usr/local/include/drogon/orm/Exception.h -- Up-to-date: /usr/local/include/drogon/orm/Field.h -- Up-to-date: /usr/local/include/drogon/orm/FunctionTraits.h -- Up-to-date: /usr/local/include/drogon/orm/Mapper.h -- Up-to-date: /usr/local/include/drogon/orm/CoroMapper.h -- Up-to-date: /usr/local/include/drogon/orm/Result.h -- Up-to-date: /usr/local/include/drogon/orm/ResultIterator.h -- Up-to-date: /usr/local/include/drogon/orm/Row.h -- Up-to-date: /usr/local/include/drogon/orm/RowIterator.h -- Up-to-date: /usr/local/include/drogon/orm/SqlBinder.h -- Up-to-date: /usr/local/include/drogon/orm/RestfulController.h -- Up-to-date: /usr/local/include/drogon/nosql/RedisClient.h -- Up-to-date: /usr/local/include/drogon/nosql/RedisResult.h -- Up-to-date: /usr/local/include/drogon/nosql/RedisException.h -- Up-to-date: /usr/local/include/drogon/utils/FunctionTraits.h -- Up-to-date: /usr/local/include/drogon/utils/Utilities.h -- Up-to-date: /usr/local/include/drogon/utils/any.h -- Up-to-date: /usr/local/include/drogon/utils/string_view.h -- Up-to-date: /usr/local/include/drogon/utils/optional.h -- Up-to-date: /usr/local/include/drogon/utils/coroutine.h -- Up-to-date: /usr/local/include/drogon/utils/HttpConstraint.h -- Up-to-date: /usr/local/include/drogon/utils/OStringStream.h -- Up-to-date: /usr/local/include/drogon/plugins/Plugin.h -- Up-to-date: /usr/local/include/drogon/plugins/SecureSSLRedirector.h -- Up-to-date: /usr/local/include/drogon/plugins/AccessLogger.h -- Up-to-date: /usr/local/lib/cmake/Drogon/DrogonConfig.cmake -- Up-to-date: /usr/local/lib/cmake/Drogon/DrogonConfigVersion.cmake -- Up-to-date: /usr/local/lib/cmake/Drogon/FindUUID.cmake -- Up-to-date: /usr/local/lib/cmake/Drogon/FindJsoncpp.cmake -- Up-to-date: /usr/local/lib/cmake/Drogon/FindSQLite3.cmake -- Up-to-date: /usr/local/lib/cmake/Drogon/FindMySQL.cmake -- Up-to-date: /usr/local/lib/cmake/Drogon/Findpg.cmake -- Up-to-date: /usr/local/lib/cmake/Drogon/FindBrotli.cmake -- Up-to-date: /usr/local/lib/cmake/Drogon/Findcoz-profiler.cmake -- Up-to-date: /usr/local/lib/cmake/Drogon/FindHiredis.cmake -- Up-to-date: /usr/local/lib/cmake/Drogon/FindFilesystem.cmake -- Up-to-date: /usr/local/lib/cmake/Drogon/DrogonUtilities.cmake -- Up-to-date: /usr/local/lib/cmake/Drogon/ParseAndAddDrogonTests.cmake -- Up-to-date: /usr/local/lib/cmake/Drogon/DrogonTargets.cmake -- Up-to-date: /usr/local/lib/cmake/Drogon/DrogonTargets-noconfig.cmake -- Up-to-date: /usr/local/lib/libtrantor.a -- Up-to-date: /usr/local/include/trantor/exports.h -- Up-to-date: /usr/local/include/trantor/net/EventLoop.h -- Up-to-date: /usr/local/include/trantor/net/EventLoopThread.h -- Up-to-date: /usr/local/include/trantor/net/EventLoopThreadPool.h -- Up-to-date: /usr/local/include/trantor/net/InetAddress.h -- Up-to-date: /usr/local/include/trantor/net/TcpClient.h -- Up-to-date: /usr/local/include/trantor/net/TcpConnection.h -- Up-to-date: /usr/local/include/trantor/net/TcpServer.h -- Up-to-date: /usr/local/include/trantor/net/callbacks.h -- Up-to-date: /usr/local/include/trantor/net/Resolver.h -- Up-to-date: /usr/local/include/trantor/net/Channel.h -- Up-to-date: /usr/local/include/trantor/utils/AsyncFileLogger.h -- Up-to-date: /usr/local/include/trantor/utils/ConcurrentTaskQueue.h -- Up-to-date: /usr/local/include/trantor/utils/Date.h -- Up-to-date: /usr/local/include/trantor/utils/Funcs.h -- Up-to-date: /usr/local/include/trantor/utils/LockFreeQueue.h -- Up-to-date: /usr/local/include/trantor/utils/LogStream.h -- Up-to-date: /usr/local/include/trantor/utils/Logger.h -- Up-to-date: /usr/local/include/trantor/utils/MsgBuffer.h -- Up-to-date: /usr/local/include/trantor/utils/NonCopyable.h -- Up-to-date: /usr/local/include/trantor/utils/ObjectPool.h -- Up-to-date: /usr/local/include/trantor/utils/SerialTaskQueue.h -- Up-to-date: /usr/local/include/trantor/utils/TaskQueue.h -- Up-to-date: /usr/local/include/trantor/utils/TimingWheel.h -- Up-to-date: /usr/local/include/trantor/utils/Utilities.h -- Up-to-date: /usr/local/lib/cmake/Trantor/TrantorConfig.cmake -- Up-to-date: /usr/local/lib/cmake/Trantor/TrantorConfigVersion.cmake -- Up-to-date: /usr/local/lib/cmake/Trantor/Findc-ares.cmake -- Up-to-date: /usr/local/lib/cmake/Trantor/TrantorTargets.cmake -- Up-to-date: /usr/local/lib/cmake/Trantor/TrantorTargets-noconfig.cmake -- Up-to-date: /usr/local/bin/drogon_ctl -- Up-to-date: /usr/local/bin/dg_ctl -- Up-to-date: /usr/local/cmake/jwt-cpp-targets.cmake -- Up-to-date: /usr/local/include/jwt-cpp/jwt.h -- Up-to-date: /usr/local/include/jwt-cpp/base.h -- Up-to-date: /usr/local/include/picojson/picojson.h -- Up-to-date: /usr/local/cmake/jwt-cpp-config.cmake -- Up-to-date: /usr/local/cmake/jwt-cpp-config-version.cmake 20211022 17:21:42.615773 UTC 81375 TRACE [loadListeners] Has 1 listeners - ConfigLoader.cc:581 20211022 17:21:42.615851 UTC 81375 TRACE [loadListeners] Add listener:0.0.0.0:8080 - ConfigLoader.cc:605 20211022 17:21:42.615951 UTC 81375 TRACE [run] Start to run... - HttpAppFrameworkImpl.cc:449 20211022 17:21:42.616938 UTC 81375 TRACE [createListeners] thread num=4 - ListenerManager.cc:98 20211022 17:21:42.617277 UTC 81375 TRACE [createNonblockingSocketOrDie] sock=11 - Socket.h:46 20211022 17:21:42.617350 UTC 81375 TRACE [IgnoreSigPipe] Ignore SIGPIPE - TcpServer.h:238 20211022 17:21:42.617382 UTC 81375 TRACE [createNonblockingSocketOrDie] sock=13 - Socket.h:46 20211022 17:21:42.617404 UTC 81375 TRACE [IgnoreSigPipe] Ignore SIGPIPE - TcpServer.h:238 20211022 17:21:42.617422 UTC 81375 TRACE [~TcpServer] TcpServer::~TcpServer [drogonPortTest] destructing - TcpServer.cc:45 20211022 17:21:42.617474 UTC 81375 TRACE [~Socket] Socket deconstructed:11 - Socket.cc:241 20211022 17:21:42.617509 UTC 81375 TRACE [start] HttpServer[drogon] starts listenning on 0.0.0.0:8080 - HttpServer.cc:184 20211022 17:21:42.617531 UTC 81375 TRACE [createListeners] thread num=4 - ListenerManager.cc:98 20211022 17:21:42.617738 UTC 81375 TRACE [createNonblockingSocketOrDie] sock=15 - Socket.h:46 20211022 17:21:42.617774 UTC 81375 TRACE [IgnoreSigPipe] Ignore SIGPIPE - TcpServer.h:238 20211022 17:21:42.617795 UTC 81375 TRACE [start] HttpServer[drogon] starts listenning on 0.0.0.0:8080 - HttpServer.cc:184 20211022 17:21:42.617812 UTC 81375 TRACE [createListeners] thread num=4 - ListenerManager.cc:98 20211022 17:21:42.617979 UTC 81375 TRACE [createNonblockingSocketOrDie] sock=20 - Socket.h:46 20211022 17:21:42.618000 UTC 81375 TRACE [IgnoreSigPipe] Ignore SIGPIPE - TcpServer.h:238 20211022 17:21:42.618012 UTC 81375 TRACE [start] HttpServer[drogon] starts listenning on 0.0.0.0:8080 - HttpServer.cc:184 20211022 17:21:42.618020 UTC 81375 TRACE [createListeners] thread num=4 - ListenerManager.cc:98 20211022 17:21:42.618194 UTC 81375 TRACE [createNonblockingSocketOrDie] sock=25 - Socket.h:46 20211022 17:21:42.618216 UTC 81375 TRACE [IgnoreSigPipe] Ignore SIGPIPE - TcpServer.h:238 20211022 17:21:42.618228 UTC 81375 TRACE [start] HttpServer[drogon] starts listenning on 0.0.0.0:8080 - HttpServer.cc:184 20211022 17:21:42.618246 UTC 81375 TRACE [operator()] create fast database client for the thread 0 - DbClientManager.cc:67 20211022 17:21:42.618255 UTC 81375 TRACE [DbClientLockFree] type=1 - DbClientLockFree.cc:56 20211022 17:21:42.618262 UTC 81375 TRACE [operator()] create fast database client for the thread 1 - DbClientManager.cc:67 20211022 17:21:42.618273 UTC 81375 TRACE [DbClientLockFree] type=1 - DbClientLockFree.cc:56 20211022 17:21:42.618284 UTC 81375 TRACE [operator()] create fast database client for the thread 2 - DbClientManager.cc:67 20211022 17:21:42.618300 UTC 81375 TRACE [DbClientLockFree] type=1 - DbClientLockFree.cc:56 20211022 17:21:42.618317 UTC 81375 TRACE [operator()] create fast database client for the thread 3 - DbClientManager.cc:67 20211022 17:21:42.618331 UTC 81375 TRACE [DbClientLockFree] type=1 - DbClientLockFree.cc:56 20211022 17:21:42.618346 UTC 81375 TRACE [operator()] create fast database client for the thread 4 - DbClientManager.cc:67 20211022 17:21:42.618381 UTC 81375 TRACE [DbClientLockFree] type=1 - DbClientLockFree.cc:56 20211022 17:21:42.619011 UTC 81375 TRACE [createHandlerInstance] create handler class object: 0x564A8FA101D0 - HttpBinder.h:138 20211022 17:21:42.619030 UTC 81375 TRACE [createHandlerInstance] create handler class object: 0x564A8FA101D0 - HttpBinder.h:138 20211022 17:21:42.619044 UTC 81375 TRACE [createHandlerInstance] create handler class object: 0x564A8FA101D0 - HttpBinder.h:138 20211022 17:21:42.619060 UTC 81375 TRACE [createHandlerInstance] create handler class object: 0x564A8FA101D0 - HttpBinder.h:138 20211022 17:21:42.619113 UTC 81375 TRACE [createHandlerInstance] create handler class object: 0x564A8FA16920 - HttpBinder.h:138 20211022 17:21:42.619136 UTC 81375 TRACE [createHandlerInstance] create handler class object: 0x564A8FA16920 - HttpBinder.h:138 20211022 17:21:42.619153 UTC 81375 TRACE [createHandlerInstance] create handler class object: 0x564A8FA16920 - HttpBinder.h:138 20211022 17:21:42.619169 UTC 81375 TRACE [createHandlerInstance] create handler class object: 0x564A8E2C4BB0 - HttpBinder.h:146 20211022 17:21:42.619177 UTC 81375 TRACE [createHandlerInstance] create handler class object: 0x564A8E2C4BD0 - HttpBinder.h:146 20211022 17:21:42.619183 UTC 81375 TRACE [createHandlerInstance] create handler class object: 0x564A8E2C4BD0 - HttpBinder.h:146 20211022 17:21:42.619191 UTC 81375 TRACE [createHandlerInstance] create handler class object: 0x564A8E2C4BD0 - HttpBinder.h:146 20211022 17:21:42.619206 UTC 81375 TRACE [createHandlerInstance] create handler class object: 0x564A8E2C4BD0 - HttpBinder.h:146 20211022 17:21:42.619229 UTC 81375 TRACE [createHandlerInstance] create handler class object: 0x564A8FA174A0 - HttpBinder.h:138 20211022 17:21:42.619270 UTC 81375 TRACE [createHandlerInstance] create handler class object: 0x564A8FA174A0 - HttpBinder.h:138 20211022 17:21:42.619289 UTC 81375 TRACE [createHandlerInstance] create handler class object: 0x564A8E2C4D30 - HttpBinder.h:146 20211022 17:21:42.619305 UTC 81375 TRACE [createHandlerInstance] create handler class object: 0x564A8E2C4D30 - HttpBinder.h:146 20211022 17:21:42.619320 UTC 81375 TRACE [createHandlerInstance] create handler class object: 0x564A8E2C4D30 - HttpBinder.h:146 20211022 17:21:42.619326 UTC 81375 TRACE [createHandlerInstance] create handler class object: 0x564A8E2C4D30 - HttpBinder.h:146 20211022 17:21:42.619333 UTC 81375 TRACE [createHandlerInstance] create handler class object: 0x564A8E2C4D30 - HttpBinder.h:146 20211022 17:21:42.619349 UTC 81375 TRACE [createHandlerInstance] create handler class object: 0x564A8E2C4D50 - HttpBinder.h:146 20211022 17:21:42.622651 UTC 81376 TRACE [operator()] map size=1 - TcpServer.cc:142 20211022 17:21:42.622699 UTC 81377 TRACE [operator()] map size=1 - TcpServer.cc:142 20211022 17:21:42.622726 UTC 81378 TRACE [operator()] map size=1 - TcpServer.cc:142 20211022 17:21:42.623044 UTC 81379 TRACE [operator()] map size=1 - TcpServer.cc:142 20211022 17:21:42.652278 UTC 81375 TRACE [operator()] connected! - DbClientLockFree.cc:457 20211022 17:21:42.652798 UTC 81376 TRACE [operator()] connected! - DbClientLockFree.cc:457 20211022 17:21:42.652798 UTC 81378 TRACE [operator()] connected! - DbClientLockFree.cc:457 20211022 17:21:42.652803 UTC 81377 TRACE [operator()] connected! - DbClientLockFree.cc:457 20211022 17:21:42.652902 UTC 81379 TRACE [operator()] connected! - DbClientLockFree.cc:457 20211022 17:21:54.516532 UTC 81379 TRACE [newConnection] new connection:fd=31 address=192.168.1.254:42932 - TcpServer.cc:50 20211022 17:21:54.516644 UTC 81379 TRACE [TcpConnectionImpl] new connection:192.168.1.254:42932->192.168.1.253:8080 - TcpConnectionImpl.cc:376 20211022 17:21:54.516814 UTC 81379 TRACE [operator()] connectEstablished - TcpConnectionImpl.cc:837 20211022 17:21:54.516908 UTC 81379 TRACE [onConnection] connect!!!100000 num=0 - HttpAppFrameworkImpl.cc:605 20211022 17:21:54.517083 UTC 81379 TRACE [onAsyncRequest] new request:192.168.1.254:42932->192.168.1.253:8080 - HttpAppFrameworkImpl.cc:818 20211022 17:21:54.517140 UTC 81379 TRACE [onAsyncRequest] Headers GET /v1/user - HttpAppFrameworkImpl.cc:820 20211022 17:21:54.517148 UTC 81379 TRACE [onAsyncRequest] http path=/v1/user - HttpAppFrameworkImpl.cc:821 20211022 17:21:54.518130 UTC 81379 TRACE [execSqlInLoop] SELECT u.id, u.first_name, u.last_name, u.email, u.password, u.image, u.billing_address, u.shipping_address, u.mobile_number, u.enabled, IFNULL(s.hasSubscription, FALSE) AS hasSubscription, s.subscriptionExpiresAt FROM users u LEFT OUTER JOIN (SELECT s.id_user, CASE WHEN COUNT(s.id) > 0 THEN TRUE ELSE FALSE END AS hasSubscription, @expiresAt AS subscriptionExpiresAt FROM subscriptions s INNER JOIN plans p ON p.id = s.id_plan INNER JOIN payment_logs pl ON pl.id = s.id_payment_log WHERE pl.completed IS NOT NULL AND TIMESTAMP(NOW()) BETWEEN pl.completed AND @expiresAt := TIMESTAMP(DATE_ADD(pl.completed, INTERVAL p.duration MINUTE)) ORDER BY @expiresAt DESC LIMIT 1) s ON s.id_user = u.id WHERE u.id = 5; - MysqlConnection.cc:400 20211022 17:21:54.518179 UTC 81379 TRACE [execSqlInLoop] SELECT u.id, u.first_name, u.last_name, u.email, u.password, u.image, u.billing_address, u.shipping_address, u.mobile_number, u.enabled, IFNULL(s.hasSubscription, FALSE) AS hasSubscription, s.subscriptionExpiresAt FROM users u LEFT OUTER JOIN (SELECT s.id_user, CASE WHEN COUNT(s.id) > 0 THEN TRUE ELSE FALSE END AS hasSubscription, @expiresAt AS subscriptionExpiresAt FROM subscriptions s INNER JOIN plans p ON p.id = s.id_plan INNER JOIN payment_logs pl ON pl.id = s.id_payment_log WHERE pl.completed IS NOT NULL AND TIMESTAMP(NOW()) BETWEEN pl.completed AND @expiresAt := TIMESTAMP(DATE_ADD(pl.completed, INTERVAL p.duration MINUTE)) ORDER BY @expiresAt DESC LIMIT 1) s ON s.id_user = u.id WHERE u.id = 5; - MysqlConnection.cc:484 20211022 17:21:54.518280 UTC 81379 TRACE [execSqlInLoop] real_query:1 - MysqlConnection.cc:492 20211022 17:21:54.531173 UTC 81379 TRACE [handleEvent] real_query:0 - MysqlConnection.cc:273 20211022 17:21:54.531206 UTC 81379 TRACE [handleEvent] store_result_start:0 - MysqlConnection.cc:287 20211022 17:21:54.531289 UTC 81379 DEBUG [operator()] Row: id - Value: 5 - Is null: 0 - UserFilter.cc:25 20211022 17:21:54.531312 UTC 81379 DEBUG [operator()] Row: first_name - Value: Joao - Is null: 0 - UserFilter.cc:25 20211022 17:21:54.531320 UTC 81379 DEBUG [operator()] Row: last_name - Value: Fernandes - Is null: 0 - UserFilter.cc:25 20211022 17:21:54.531327 UTC 81379 DEBUG [operator()] Row: email - Value: - Is null: 0 - UserFilter.cc:25 20211022 17:21:54.531337 UTC 81379 DEBUG [operator()] Row: password - Value: - Is null: 0 - UserFilter.cc:25 20211022 17:21:54.531347 UTC 81379 DEBUG [operator()] Row: image - Value: - Is null: 1 - UserFilter.cc:25 20211022 17:21:54.531354 UTC 81379 DEBUG [operator()] Row: billing_address - Value: 26 - Is null: 0 - UserFilter.cc:25 20211022 17:21:54.531363 UTC 81379 DEBUG [operator()] Row: shipping_address - Value: 28 - Is null: 0 - UserFilter.cc:25 20211022 17:21:54.531383 UTC 81379 DEBUG [operator()] Row: mobile_number - Value: - Is null: 0 - UserFilter.cc:25 20211022 17:21:54.531395 UTC 81379 DEBUG [operator()] Row: enabled - Value: 1 - Is null: 0 - UserFilter.cc:25 20211022 17:21:54.531411 UTC 81379 DEBUG [operator()] Row: hasSubscription - Value: 1 - Is null: 0 - UserFilter.cc:25 20211022 17:21:54.531459 UTC 81379 DEBUG [operator()] Row: subscriptionExpiresAt - Value: - Is null: 1 - UserFilter.cc:25 20211022 17:21:54.531574 UTC 81379 DEBUG [UserHolder] Timestamp debug: - User.h:20 20211022 17:21:54.531674 UTC 81379 DEBUG [get] | 1 | -11130 00:36:45 - User.cc:9 20211022 17:21:54.531941 UTC 81379 TRACE [renderToBuffer] reponse(no body):HTTP/1.1 200 OK content-length: 211 content-type: application/json; charset=utf-8 server: WebService access-control-allow-origin: * date: Fri, 22 Oct 2021 17:21:54 GMT - HttpResponseImpl.cc:614 20211022 17:21:54.532634 UTC 81379 TRACE [handleClose] connection closed, fd=31 - TcpConnectionImpl.cc:872 20211022 17:21:54.532672 UTC 81379 TRACE [onConnection] conn disconnected! - HttpServer.cc:203 20211022 17:21:54.532681 UTC 81379 TRACE [onConnection] connect!!!100000 num=1 - HttpAppFrameworkImpl.cc:605 20211022 17:21:54.532703 UTC 81379 TRACE [handleClose] to call close callback - TcpConnectionImpl.cc:882 20211022 17:21:54.532712 UTC 81379 TRACE [connectionClosed] connectionClosed - TcpServer.cc:167 20211022 17:21:54.532731 UTC 81379 TRACE [~Socket] Socket deconstructed:31 - Socket.cc:241 20211022 17:21:56.902866 UTC 81376 TRACE [newConnection] new connection:fd=31 address=192.168.1.254:42934 - TcpServer.cc:50 20211022 17:21:56.902975 UTC 81376 TRACE [TcpConnectionImpl] new connection:192.168.1.254:42934->192.168.1.253:8080 - TcpConnectionImpl.cc:376 20211022 17:21:56.903051 UTC 81376 TRACE [operator()] connectEstablished - TcpConnectionImpl.cc:837 20211022 17:21:56.903137 UTC 81376 TRACE [onConnection] connect!!!100000 num=0 - HttpAppFrameworkImpl.cc:605 20211022 17:21:56.903281 UTC 81376 TRACE [onAsyncRequest] new request:192.168.1.254:42934->192.168.1.253:8080 - HttpAppFrameworkImpl.cc:818 20211022 17:21:56.903323 UTC 81376 TRACE [onAsyncRequest] Headers GET /v1/user - HttpAppFrameworkImpl.cc:820 20211022 17:21:56.903335 UTC 81376 TRACE [onAsyncRequest] http path=/v1/user - HttpAppFrameworkImpl.cc:821 20211022 17:21:56.904057 UTC 81376 TRACE [execSqlInLoop] SELECT u.id, u.first_name, u.last_name, u.email, u.password, u.image, u.billing_address, u.shipping_address, u.mobile_number, u.enabled, IFNULL(s.hasSubscription, FALSE) AS hasSubscription, s.subscriptionExpiresAt FROM users u LEFT OUTER JOIN (SELECT s.id_user, CASE WHEN COUNT(s.id) > 0 THEN TRUE ELSE FALSE END AS hasSubscription, @expiresAt AS subscriptionExpiresAt FROM subscriptions s INNER JOIN plans p ON p.id = s.id_plan INNER JOIN payment_logs pl ON pl.id = s.id_payment_log WHERE pl.completed IS NOT NULL AND TIMESTAMP(NOW()) BETWEEN pl.completed AND @expiresAt := TIMESTAMP(DATE_ADD(pl.completed, INTERVAL p.duration MINUTE)) ORDER BY @expiresAt DESC LIMIT 1) s ON s.id_user = u.id WHERE u.id = 5; - MysqlConnection.cc:400 20211022 17:21:56.904142 UTC 81376 TRACE [execSqlInLoop] SELECT u.id, u.first_name, u.last_name, u.email, u.password, u.image, u.billing_address, u.shipping_address, u.mobile_number, u.enabled, IFNULL(s.hasSubscription, FALSE) AS hasSubscription, s.subscriptionExpiresAt FROM users u LEFT OUTER JOIN (SELECT s.id_user, CASE WHEN COUNT(s.id) > 0 THEN TRUE ELSE FALSE END AS hasSubscription, @expiresAt AS subscriptionExpiresAt FROM subscriptions s INNER JOIN plans p ON p.id = s.id_plan INNER JOIN payment_logs pl ON pl.id = s.id_payment_log WHERE pl.completed IS NOT NULL AND TIMESTAMP(NOW()) BETWEEN pl.completed AND @expiresAt := TIMESTAMP(DATE_ADD(pl.completed, INTERVAL p.duration MINUTE)) ORDER BY @expiresAt DESC LIMIT 1) s ON s.id_user = u.id WHERE u.id = 5; - MysqlConnection.cc:484 20211022 17:21:56.904183 UTC 81376 TRACE [execSqlInLoop] real_query:1 - MysqlConnection.cc:492 20211022 17:21:56.917923 UTC 81376 TRACE [handleEvent] real_query:0 - MysqlConnection.cc:273 20211022 17:21:56.917949 UTC 81376 TRACE [handleEvent] store_result_start:0 - MysqlConnection.cc:287 20211022 17:21:56.917981 UTC 81376 DEBUG [operator()] Row: id - Value: 5 - Is null: 0 - UserFilter.cc:25 20211022 17:21:56.917986 UTC 81376 DEBUG [operator()] Row: first_name - Value: Joao - Is null: 0 - UserFilter.cc:25 20211022 17:21:56.917990 UTC 81376 DEBUG [operator()] Row: last_name - Value: Fernandes - Is null: 0 - UserFilter.cc:25 20211022 17:21:56.917993 UTC 81376 DEBUG [operator()] Row: email - Value: - Is null: 0 - UserFilter.cc:25 20211022 17:21:56.917997 UTC 81376 DEBUG [operator()] Row: password - Value: - Is null: 0 - UserFilter.cc:25 20211022 17:21:56.918001 UTC 81376 DEBUG [operator()] Row: image - Value: - Is null: 1 - UserFilter.cc:25 20211022 17:21:56.918005 UTC 81376 DEBUG [operator()] Row: billing_address - Value: 26 - Is null: 0 - UserFilter.cc:25 20211022 17:21:56.918018 UTC 81376 DEBUG [operator()] Row: shipping_address - Value: 28 - Is null: 0 - UserFilter.cc:25 20211022 17:21:56.918029 UTC 81376 DEBUG [operator()] Row: mobile_number - Value: - Is null: 0 - UserFilter.cc:25 20211022 17:21:56.918040 UTC 81376 DEBUG [operator()] Row: enabled - Value: 1 - Is null: 0 - UserFilter.cc:25 20211022 17:21:56.918057 UTC 81376 DEBUG [operator()] Row: hasSubscription - Value: 1 - Is null: 0 - UserFilter.cc:25 20211022 17:21:56.918068 UTC 81376 DEBUG [operator()] Row: subscriptionExpiresAt - Value: - Is null: 1 - UserFilter.cc:25 20211022 17:21:56.918142 UTC 81376 DEBUG [UserHolder] Timestamp debug: - User.h:20 20211022 17:21:56.918183 UTC 81376 DEBUG [get] | 1 | -11130 00:36:45 - User.cc:9 20211022 17:21:56.918256 UTC 81376 TRACE [renderToBuffer] reponse(no body):HTTP/1.1 200 OK content-length: 211 content-type: application/json; charset=utf-8 server: WebService access-control-allow-origin: * date: Fri, 22 Oct 2021 17:21:56 GMT - HttpResponseImpl.cc:614 20211022 17:21:56.919017 UTC 81376 TRACE [handleClose] connection closed, fd=31 - TcpConnectionImpl.cc:872 20211022 17:21:56.919039 UTC 81376 TRACE [onConnection] conn disconnected! - HttpServer.cc:203 20211022 17:21:56.919044 UTC 81376 TRACE [onConnection] connect!!!100000 num=1 - HttpAppFrameworkImpl.cc:605 20211022 17:21:56.919056 UTC 81376 TRACE [handleClose] to call close callback - TcpConnectionImpl.cc:882 20211022 17:21:56.919061 UTC 81376 TRACE [connectionClosed] connectionClosed - TcpServer.cc:167 20211022 17:21:56.919071 UTC 81376 TRACE [~Socket] Socket deconstructed:31 - Socket.cc:241 20211022 17:21:57.588612 UTC 81379 TRACE [newConnection] new connection:fd=31 address=192.168.1.254:42936 - TcpServer.cc:50 20211022 17:21:57.588669 UTC 81379 TRACE [TcpConnectionImpl] new connection:192.168.1.254:42936->192.168.1.253:8080 - TcpConnectionImpl.cc:376 20211022 17:21:57.588716 UTC 81379 TRACE [operator()] connectEstablished - TcpConnectionImpl.cc:837 20211022 17:21:57.588749 UTC 81379 TRACE [onConnection] connect!!!100000 num=0 - HttpAppFrameworkImpl.cc:605 20211022 17:21:57.588891 UTC 81379 TRACE [onAsyncRequest] new request:192.168.1.254:42936->192.168.1.253:8080 - HttpAppFrameworkImpl.cc:818 20211022 17:21:57.589073 UTC 81379 TRACE [onAsyncRequest] Headers GET /v1/user - HttpAppFrameworkImpl.cc:820 20211022 17:21:57.589094 UTC 81379 TRACE [onAsyncRequest] http path=/v1/user - HttpAppFrameworkImpl.cc:821 20211022 17:21:57.589831 UTC 81379 TRACE [execSqlInLoop] SELECT u.id, u.first_name, u.last_name, u.email, u.password, u.image, u.billing_address, u.shipping_address, u.mobile_number, u.enabled, IFNULL(s.hasSubscription, FALSE) AS hasSubscription, s.subscriptionExpiresAt FROM users u LEFT OUTER JOIN (SELECT s.id_user, CASE WHEN COUNT(s.id) > 0 THEN TRUE ELSE FALSE END AS hasSubscription, @expiresAt AS subscriptionExpiresAt FROM subscriptions s INNER JOIN plans p ON p.id = s.id_plan INNER JOIN payment_logs pl ON pl.id = s.id_payment_log WHERE pl.completed IS NOT NULL AND TIMESTAMP(NOW()) BETWEEN pl.completed AND @expiresAt := TIMESTAMP(DATE_ADD(pl.completed, INTERVAL p.duration MINUTE)) ORDER BY @expiresAt DESC LIMIT 1) s ON s.id_user = u.id WHERE u.id = 5; - MysqlConnection.cc:400 20211022 17:21:57.589866 UTC 81379 TRACE [execSqlInLoop] SELECT u.id, u.first_name, u.last_name, u.email, u.password, u.image, u.billing_address, u.shipping_address, u.mobile_number, u.enabled, IFNULL(s.hasSubscription, FALSE) AS hasSubscription, s.subscriptionExpiresAt FROM users u LEFT OUTER JOIN (SELECT s.id_user, CASE WHEN COUNT(s.id) > 0 THEN TRUE ELSE FALSE END AS hasSubscription, @expiresAt AS subscriptionExpiresAt FROM subscriptions s INNER JOIN plans p ON p.id = s.id_plan INNER JOIN payment_logs pl ON pl.id = s.id_payment_log WHERE pl.completed IS NOT NULL AND TIMESTAMP(NOW()) BETWEEN pl.completed AND @expiresAt := TIMESTAMP(DATE_ADD(pl.completed, INTERVAL p.duration MINUTE)) ORDER BY @expiresAt DESC LIMIT 1) s ON s.id_user = u.id WHERE u.id = 5; - MysqlConnection.cc:484 20211022 17:21:57.589901 UTC 81379 TRACE [execSqlInLoop] real_query:1 - MysqlConnection.cc:492 20211022 17:21:57.600655 UTC 81379 TRACE [handleEvent] real_query:0 - MysqlConnection.cc:273 20211022 17:21:57.600686 UTC 81379 TRACE [handleEvent] store_result_start:0 - MysqlConnection.cc:287 20211022 17:21:57.600771 UTC 81379 DEBUG [operator()] Row: id - Value: 5 - Is null: 0 - UserFilter.cc:25 20211022 17:21:57.600802 UTC 81379 DEBUG [operator()] Row: first_name - Value: Joao - Is null: 0 - UserFilter.cc:25 20211022 17:21:57.600817 UTC 81379 DEBUG [operator()] Row: last_name - Value: Fernandes - Is null: 0 - UserFilter.cc:25 20211022 17:21:57.600852 UTC 81379 DEBUG [operator()] Row: email - Value: - Is null: 0 - UserFilter.cc:25 20211022 17:21:57.600861 UTC 81379 DEBUG [operator()] Row: password - Value: - Is null: 0 - UserFilter.cc:25 20211022 17:21:57.600868 UTC 81379 DEBUG [operator()] Row: image - Value: - Is null: 1 - UserFilter.cc:25 20211022 17:21:57.600885 UTC 81379 DEBUG [operator()] Row: billing_address - Value: 26 - Is null: 0 - UserFilter.cc:25 20211022 17:21:57.600893 UTC 81379 DEBUG [operator()] Row: shipping_address - Value: 28 - Is null: 0 - UserFilter.cc:25 20211022 17:21:57.600910 UTC 81379 DEBUG [operator()] Row: mobile_number - Value: - Is null: 0 - UserFilter.cc:25 20211022 17:21:57.600929 UTC 81379 DEBUG [operator()] Row: enabled - Value: 1 - Is null: 0 - UserFilter.cc:25 20211022 17:21:57.600940 UTC 81379 DEBUG [operator()] Row: hasSubscription - Value: 1 - Is null: 0 - UserFilter.cc:25 20211022 17:21:57.600956 UTC 81379 DEBUG [operator()] Row: subscriptionExpiresAt - Value: 2021-10-23 18:00:00 - Is null: 0 - UserFilter.cc:25 20211022 17:21:57.601104 UTC 81379 DEBUG [UserHolder] Timestamp debug: 2021-10-23 18:00:00 - User.h:20 20211022 17:21:57.601266 UTC 81379 DEBUG [get] | 1 | 20211023 17:00:00 - User.cc:9 20211022 17:21:57.601537 UTC 81379 TRACE [renderToBuffer] reponse(no body):HTTP/1.1 200 OK content-length: 211 content-type: application/json; charset=utf-8 server: WebService access-control-allow-origin: * date: Fri, 22 Oct 2021 17:21:57 GMT - HttpResponseImpl.cc:614 20211022 17:21:57.602123 UTC 81379 TRACE [handleClose] connection closed, fd=31 - TcpConnectionImpl.cc:872 20211022 17:21:57.602156 UTC 81379 TRACE [onConnection] conn disconnected! - HttpServer.cc:203 20211022 17:21:57.602165 UTC 81379 TRACE [onConnection] connect!!!100000 num=1 - HttpAppFrameworkImpl.cc:605 20211022 17:21:57.602186 UTC 81379 TRACE [handleClose] to call close callback - TcpConnectionImpl.cc:882 20211022 17:21:57.602194 UTC 81379 TRACE [connectionClosed] connectionClosed - TcpServer.cc:167 20211022 17:21:57.602212 UTC 81379 TRACE [~Socket] Socket deconstructed:31 - Socket.cc:241 ```
UserFilter.h: ```cpp #pragma once #include #include #include #include #include using namespace drogon; using namespace drogon_model::mdtdb; using namespace api::utils::http; using namespace api::utils::constants; using namespace api::utils::models; namespace v1::filters { class UserFilter : public HttpFilter { public: UserFilter() = default; virtual void doFilter(const HttpRequestPtr &request, FilterCallback &&fcb, FilterChainCallback &&fccb) override; private: IOThreadStorage _dbClient; }; } ```
UserFilter.cc: ```cpp #include "UserFilter.h" using namespace v1::filters; void UserFilter::doFilter(const HttpRequestPtr &request, FilterCallback &&fcb, FilterChainCallback &&fccb) { if (!*_dbClient) *_dbClient = app().getFastDbClient(); (*_dbClient)->execSqlAsync("SELECT u.id, u.first_name, u.last_name, u.email, u.password, u.image, u.billing_address, u.shipping_address, u.mobile_number, u.enabled, IFNULL(s.hasSubscription, FALSE) AS hasSubscription, s.subscriptionExpiresAt FROM users u LEFT OUTER JOIN (SELECT s.id_user, CASE WHEN COUNT(s.id) > 0 THEN TRUE ELSE FALSE END AS hasSubscription, @expiresAt AS subscriptionExpiresAt FROM subscriptions s INNER JOIN plans p ON p.id = s.id_plan INNER JOIN payment_logs pl ON pl.id = s.id_payment_log WHERE pl.completed IS NOT NULL AND TIMESTAMP(NOW()) BETWEEN pl.completed AND @expiresAt := TIMESTAMP(DATE_ADD(pl.completed, INTERVAL p.duration MINUTE)) ORDER BY @expiresAt DESC LIMIT 1) s ON s.id_user = u.id WHERE u.id = 5;", [request, fcb, fccb](const Result &result) { if (result.affectedRows() == 1) { // Verify if account ins't banned. if (!result[0][Users::Cols::_enabled].as()) { HttpResponsePtr res = CHttpResponse(AuthConst::ACCOUNT_BANNED); res->setStatusCode(k401Unauthorized); return fcb(res); } const Row& row(result[0]); for (const auto &item : row) { LOG_DEBUG << "Row: " << item.name() << " - Value: " << item.as() << " - Is null: " << item.isNull(); } const Users user(row); // Save the user on attributes, for next endpoint able to get the user object. request->getAttributes()->insert("user", UserHolder(user, row["hasSubscription"].as(), row["subscriptionExpiresAt"].as())); // Move to next endpoint return fccb(); } return fcb(CHttpResponse::unknownError()); }, [fcb](const DrogonDbException &e) { HttpResponsePtr res = CHttpResponse(AuthConst::ACCOUNT_WRONG_TOKEN); res->setStatusCode(k406NotAcceptable); return fcb(res); } ); } ```
marty1885 commented 2 years ago

Thanks for reporting. I'll have to ask an-tao for that.

BTW, MSYS2 have updated to GCC 11.2. Hopefully you can have coroutines working now

0rangeFox commented 2 years ago

It has been a long time, so maybe the problem has already been solved. If not, I will reopen this issue with more detailed information.