diff options
author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2019-08-08 15:29:13 -0500 |
---|---|---|
committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2019-08-08 15:29:13 -0500 |
commit | 28d0070ce2e791727c388646f22119e350ab6d78 (patch) | |
tree | 9cd411fad644e021b5ccb64e47c0ab8ac74358a6 /controller/PostgreSQL.cpp | |
parent | ad2a7c2590467270486c15144330f2c3e87ec080 (diff) | |
download | infinitytier-28d0070ce2e791727c388646f22119e350ab6d78.tar.gz infinitytier-28d0070ce2e791727c388646f22119e350ab6d78.zip |
Fix race in multiple DB mirroring configurations.
Diffstat (limited to 'controller/PostgreSQL.cpp')
-rw-r--r-- | controller/PostgreSQL.cpp | 16 |
1 files changed, 2 insertions, 14 deletions
diff --git a/controller/PostgreSQL.cpp b/controller/PostgreSQL.cpp index a43e2118..66b49394 100644 --- a/controller/PostgreSQL.cpp +++ b/controller/PostgreSQL.cpp @@ -183,7 +183,7 @@ bool PostgreSQL::save(nlohmann::json &record,bool notifyListeners) if (nwid) { nlohmann::json old; get(nwid,old); - if ((!old.is_object())||(old != record)) { + if ((!old.is_object())||(!_compareRecords(old,record))) { record["revision"] = OSUtils::jsonInt(record["revision"],0ULL) + 1ULL; _commitQueue.post(std::pair<nlohmann::json,bool>(record,notifyListeners)); modified = true; @@ -195,25 +195,13 @@ bool PostgreSQL::save(nlohmann::json &record,bool notifyListeners) if ((id)&&(nwid)) { nlohmann::json network,old; get(nwid,network,id,old); - if ((!old.is_object())||(old != record)) { + if ((!old.is_object())||(!_compareRecords(old,record))) { record["revision"] = OSUtils::jsonInt(record["revision"],0ULL) + 1ULL; _commitQueue.post(std::pair<nlohmann::json,bool>(record,notifyListeners)); modified = true; } } } - /* - waitForReady(); - if (orig) { - if (*orig != record) { - record["revision"] = OSUtils::jsonInt(record["revision"],0ULL) + 1; - _commitQueue.post(new nlohmann::json(record)); - } - } else { - record["revision"] = 1; - _commitQueue.post(new nlohmann::json(record)); - } - */ } catch (std::exception &e) { fprintf(stderr, "Error on PostgreSQL::save: %s\n", e.what()); } catch (...) { |