aboutsummaryrefslogtreecommitdiff
path: root/migrate
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2016-03-14 14:38:45 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2016-03-17 12:59:35 +0300
commit0b6b57f9acaa2ec648bf582ff67851331f8e6eef (patch)
tree7ce5da6a1c37f3674762d5514b0a34bf05e38df7 /migrate
parent637d5650b91cb1da2605e5f7049ccc8bab5591f3 (diff)
Use serializable transaction isolation level
Diffstat (limited to 'migrate')
-rw-r--r--migrate/migrate.cli6
-rw-r--r--migrate/migrate.cxx35
2 files changed, 25 insertions, 16 deletions
diff --git a/migrate/migrate.cli b/migrate/migrate.cli
index dcbf667..1d62504 100644
--- a/migrate/migrate.cli
+++ b/migrate/migrate.cli
@@ -114,8 +114,10 @@ class options
\cb{0} Successful termination.
-\cb{1} \cb{brep-migrate} or \l{brep-load(1)} instance is running. Try
+\cb{1} Fatal error.
+
+\cb{2} \cb{brep-migrate} or \l{brep-load(1)} instance is running. Try
again.
-\cb{2} Fatal error.
+\cb{3} The database recoverable error. Try again.
"
diff --git a/migrate/migrate.cxx b/migrate/migrate.cxx
index 70ba54f..aa11ecc 100644
--- a/migrate/migrate.cxx
+++ b/migrate/migrate.cxx
@@ -170,8 +170,8 @@ drop (database& db) const
{
for (const auto& s: drop_statements_)
// If the statement execution fails, the corresponding source file line
- // number is not reported. The line number could be usefull for the utility
- // implementer only. The errors seen by the end-user should not be
+ // number is not reported. The line number could be usefull for the
+ // utility implementer only. The errors seen by the end-user should not be
// statement-specific.
//
db.execute (s);
@@ -226,28 +226,30 @@ try
// If the pager failed, assume it has issued some diagnostics.
//
- return p.wait () ? 0 : 2;
+ return p.wait () ? 0 : 1;
}
if (argc > 1)
{
cerr << "error: unexpected argument encountered" << endl
<< help_info << endl;
- return 2;
+ return 1;
}
if (ops.recreate () && ops.drop ())
{
cerr << "error: inconsistent options specified" << endl
<< help_info << endl;
- return 2;
+ return 1;
}
- odb::pgsql::database db (ops.db_user (),
- ops.db_password (),
- ops.db_name (),
- ops.db_host (),
- ops.db_port ());
+ odb::pgsql::database db (
+ ops.db_user (),
+ ops.db_password (),
+ ops.db_name (),
+ ops.db_host (),
+ ops.db_port (),
+ "options='-c default_transaction_isolation=serializable'");
// Prevent several brep-migrate/load instances from updating DB
// simultaneously.
@@ -329,21 +331,26 @@ try
catch (const database_locked&)
{
cerr << "brep-migrate or brep-load instance is running" << endl;
- return 1;
+ return 2;
+}
+catch (const recoverable& e)
+{
+ cerr << "database recoverable error: " << e.what () << endl;
+ return 3;
}
catch (const cli::exception& e)
{
cerr << "error: " << e << endl << help_info << endl;
- return 2;
+ return 1;
}
catch (const failed&)
{
- return 2; // Diagnostics has already been issued.
+ return 1; // Diagnostics has already been issued.
}
// Fully qualified to avoid ambiguity with odb exception.
//
catch (const std::exception& e)
{
cerr << "error: " << e.what () << endl;
- return 2;
+ return 1;
}