提交 c9b5b84e authored 作者: Thomas Mueller's avatar Thomas Mueller

Auto-server: 'Connection is broken' instead of 'Error opening database: Lock…

Auto-server: 'Connection is broken' instead of 'Error opening database: Lock file modified in the future'.
上级 37b58591
...@@ -18,7 +18,8 @@ Change Log ...@@ -18,7 +18,8 @@ Change Log
<h1>Change Log</h1> <h1>Change Log</h1>
<h2>Next Version (unreleased)</h2> <h2>Next Version (unreleased)</h2>
<ul><li>- <ul><li>When using the auto-server mode, and if the lock file was modified in the future,
the wrong exception was thrown ('Connection is broken' instead of 'Error opening database: Lock file modified in the future').
</li></ul> </li></ul>
<h2>Version 1.1.105 (2008-12-19)</h2> <h2>Version 1.1.105 (2008-12-19)</h2>
......
This source diff could not be displayed because it is too large. You can view the blob instead.
.translator=Thomas Mueller .translator=Thomas Mueller
02000=No data is available 02000=No data is available
07001=Invalid parameter count for {0}, expected count\: {1} 07001=Invalid parameter count for {0}, expected count\: {1}
08000=Error opening database 08000=Error opening database\: {0}
08004=Wrong user name or password 08004=Wrong user name or password
21S02=Column count does not match 21S02=Column count does not match
22003=Numeric value out of range 22003=Numeric value out of range
......
...@@ -45,9 +45,9 @@ public class ErrorCode { ...@@ -45,9 +45,9 @@ public class ErrorCode {
/** /**
* The error with code <code>8000</code> is thrown when * The error with code <code>8000</code> is thrown when
* there was a problem trying to create a database lock. * there was a problem trying to create a database lock.
* See the cause for details. * See the message and cause for details.
*/ */
public static final int ERROR_OPENING_DATABASE = 8000; public static final int ERROR_OPENING_DATABASE_1 = 8000;
/** /**
* The error with code <code>8004</code> is thrown when * The error with code <code>8004</code> is thrown when
...@@ -1876,7 +1876,7 @@ public class ErrorCode { ...@@ -1876,7 +1876,7 @@ public class ErrorCode {
case INVALID_PARAMETER_COUNT_2: return "07001"; case INVALID_PARAMETER_COUNT_2: return "07001";
// 08: connection exception // 08: connection exception
case ERROR_OPENING_DATABASE: return "08000"; case ERROR_OPENING_DATABASE_1: return "08000";
case WRONG_USER_OR_PASSWORD: return "08004"; case WRONG_USER_OR_PASSWORD: return "08004";
// 21: cardinality violation // 21: cardinality violation
......
.translator=Thomas Mueller .translator=Thomas Mueller
02000=Keine Daten verf\u00FCgbar 02000=Keine Daten verf\u00FCgbar
07001=Ung\u00FCltige Anzahl Parameter f\u00FCr {0}, erwartet\: {1} 07001=Ung\u00FCltige Anzahl Parameter f\u00FCr {0}, erwartet\: {1}
08000=Fehler beim \u00D6ffnen der Datenbank 08000=Fehler beim \u00D6ffnen der Datenbank\: {0}
08004=Falscher Benutzer Name oder Passwort 08004=Falscher Benutzer Name oder Passwort
21S02=Anzahl der Felder stimmt nicht \u00FCberein 21S02=Anzahl der Felder stimmt nicht \u00FCberein
22003=Zahlenwert ausserhalb des Bereichs 22003=Zahlenwert ausserhalb des Bereichs
......
.translator=Thomas Mueller .translator=Thomas Mueller
02000=No data is available 02000=No data is available
07001=Invalid parameter count for {0}, expected count\: {1} 07001=Invalid parameter count for {0}, expected count\: {1}
08000=Error opening database 08000=Error opening database\: {0}
08004=Wrong user name or password 08004=Wrong user name or password
21S02=Column count does not match 21S02=Column count does not match
22003=Numeric value out of range 22003=Numeric value out of range
......
.translator=Dario V. Fassi .translator=Dario V. Fassi
02000=No hay datos disponibles. 02000=No hay datos disponibles.
07001=Cantidad de parametros invalidos para {0}, cantidad esperada\: {1} 07001=Cantidad de parametros invalidos para {0}, cantidad esperada\: {1}
08000=Error abriendo la base de datos 08000=Error abriendo la base de datos\: {0}
08004=Nombre de usuario \u00F3 password incorrecto 08004=Nombre de usuario \u00F3 password incorrecto
21S02=La cantidad de columnas no coincide 21S02=La cantidad de columnas no coincide
22003=Valor numerico fuera de rango 22003=Valor numerico fuera de rango
......
.translator=IKEMOTO, Masahiro .translator=IKEMOTO, Masahiro
02000=\u6709\u52B9\u306A\u30C7\u30FC\u30BF\u304C\u3042\u308A\u307E\u305B\u3093 02000=\u6709\u52B9\u306A\u30C7\u30FC\u30BF\u304C\u3042\u308A\u307E\u305B\u3093
07001={0} \u306F\u7121\u52B9\u306A\u30D1\u30E9\u30E1\u30FC\u30BF\u756A\u53F7\u3067\u3059, \u671F\u5F85\u3055\u308C\u308B\u756A\u53F7\: {1} 07001={0} \u306F\u7121\u52B9\u306A\u30D1\u30E9\u30E1\u30FC\u30BF\u756A\u53F7\u3067\u3059, \u671F\u5F85\u3055\u308C\u308B\u756A\u53F7\: {1}
08000=\u30C7\u30FC\u30BF\u30D9\u30FC\u30B9\u30AA\u30FC\u30D7\u30F3\u30A8\u30E9\u30FC 08000=\u30C7\u30FC\u30BF\u30D9\u30FC\u30B9\u30AA\u30FC\u30D7\u30F3\u30A8\u30E9\u30FC\: {0}
08004=\u30E6\u30FC\u30B6\u540D\u307E\u305F\u306F\u30D1\u30B9\u30EF\u30FC\u30C9\u304C\u4E0D\u6B63\u3067\u3059 08004=\u30E6\u30FC\u30B6\u540D\u307E\u305F\u306F\u30D1\u30B9\u30EF\u30FC\u30C9\u304C\u4E0D\u6B63\u3067\u3059
21S02=\u5217\u756A\u53F7\u304C\u4E00\u81F4\u3057\u307E\u305B\u3093 21S02=\u5217\u756A\u53F7\u304C\u4E00\u81F4\u3057\u307E\u305B\u3093
22003=\u7BC4\u56F2\u5916\u306E\u6570\u5024\u3067\u3059 22003=\u7BC4\u56F2\u5916\u306E\u6570\u5024\u3067\u3059
......
.translator=Tomek .translator=Tomek
02000=Dane nie sa dostepne 02000=Dane nie sa dostepne
07001=Niewlasciwa liczba parametrow, oczekiwano ilosci\: {0} 07001=Niewlasciwa liczba parametrow, oczekiwano ilosci\: {0}
08000=Blad otwarcia bazy danych 08000=Blad otwarcia bazy danych\: {0}
08004=Nieprawidlowy uzytkownik/haslo 08004=Nieprawidlowy uzytkownik/haslo
21S02=Niezgodna ilosc kolumn 21S02=Niezgodna ilosc kolumn
22003=Wartosc numeryczna poza zakresem 22003=Wartosc numeryczna poza zakresem
......
.translator=Eduardo Fonseca Velasques .translator=Eduardo Fonseca Velasques
02000=N\u00E3o h\u00E1 dados dispon\u00EDveis 02000=N\u00E3o h\u00E1 dados dispon\u00EDveis
07001=Quantidade de par\u00E2metros errados para {0}, experado\: {1} 07001=Quantidade de par\u00E2metros errados para {0}, experado\: {1}
08000=Erro ao abrir a base de dados 08000=Erro ao abrir a base de dados\: {0}
08004=Autentica\u00E7ao inv\u00E1lida, verifique o usu\u00E1rio ou a senha 08004=Autentica\u00E7ao inv\u00E1lida, verifique o usu\u00E1rio ou a senha
21S02=A quantidade de colunas n\u00E3o corresponde 21S02=A quantidade de colunas n\u00E3o corresponde
22003=Valor n\u00FAmerico n\u00E3o esta dentro do limite 22003=Valor n\u00FAmerico n\u00E3o esta dentro do limite
......
...@@ -16,7 +16,6 @@ import java.net.Socket; ...@@ -16,7 +16,6 @@ import java.net.Socket;
import java.net.UnknownHostException; import java.net.UnknownHostException;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.Properties; import java.util.Properties;
import org.h2.constant.ErrorCode; import org.h2.constant.ErrorCode;
import org.h2.constant.SysProperties; import org.h2.constant.SysProperties;
import org.h2.engine.Constants; import org.h2.engine.Constants;
...@@ -198,9 +197,11 @@ public class FileLock { ...@@ -198,9 +197,11 @@ public class FileLock {
out.close(); out.close();
} }
lastWrite = fs.getLastModified(fileName); lastWrite = fs.getLastModified(fileName);
trace.debug("save " + properties); if (trace.isDebugEnabled()) {
trace.debug("save " + properties);
}
} catch (IOException e) { } catch (IOException e) {
throw getException(e); throw getExceptionFatal("Could not save properties " + fileName, e);
} }
} }
...@@ -244,10 +245,12 @@ public class FileLock { ...@@ -244,10 +245,12 @@ public class FileLock {
private Properties load() throws SQLException { private Properties load() throws SQLException {
try { try {
Properties p2 = SortedProperties.loadProperties(fileName); Properties p2 = SortedProperties.loadProperties(fileName);
trace.debug("load " + p2); if (trace.isDebugEnabled()) {
trace.debug("load " + p2);
}
return p2; return p2;
} catch (IOException e) { } catch (IOException e) {
throw getException(e); throw getExceptionFatal("Could not load properties " + fileName, e);
} }
} }
...@@ -256,7 +259,7 @@ public class FileLock { ...@@ -256,7 +259,7 @@ public class FileLock {
long last = fs.getLastModified(fileName); long last = fs.getLastModified(fileName);
long dist = System.currentTimeMillis() - last; long dist = System.currentTimeMillis() - last;
if (dist < -TIME_GRANULARITY) { if (dist < -TIME_GRANULARITY) {
throw error("Lock file modified in the future: dist=" + dist); throw getExceptionFatal("Lock file modified in the future: dist=" + dist, null);
} }
if (dist < SLEEP_GAP) { if (dist < SLEEP_GAP) {
try { try {
...@@ -268,7 +271,7 @@ public class FileLock { ...@@ -268,7 +271,7 @@ public class FileLock {
return; return;
} }
} }
throw error("Lock file recently modified"); throw getExceptionFatal("Lock file recently modified", null);
} }
private void setUniqueId() { private void setUniqueId() {
...@@ -286,23 +289,23 @@ public class FileLock { ...@@ -286,23 +289,23 @@ public class FileLock {
waitUntilOld(); waitUntilOld();
String m2 = load().getProperty("method", FILE); String m2 = load().getProperty("method", FILE);
if (!m2.equals(FILE)) { if (!m2.equals(FILE)) {
throw error("Unsupported lock method " + m2); throw getExceptionFatal("Unsupported lock method " + m2, null);
} }
save(); save();
sleep(2 * sleep); sleep(2 * sleep);
if (!load().equals(properties)) { if (!load().equals(properties)) {
throw error("Locked by another process"); throw getExceptionAlreadyInUse("Locked by another process");
} }
fs.delete(fileName); fs.delete(fileName);
if (!fs.createNewFile(fileName)) { if (!fs.createNewFile(fileName)) {
throw error("Another process was faster"); throw getExceptionFatal("Another process was faster", null);
} }
} }
save(); save();
sleep(SLEEP_GAP); sleep(SLEEP_GAP);
if (!load().equals(properties)) { if (!load().equals(properties)) {
fileName = null; fileName = null;
throw error("Concurrent update"); throw getExceptionFatal("Concurrent update", null);
} }
Thread watchdog = new Thread(new Runnable() { Thread watchdog = new Thread(new Runnable() {
public void run() { public void run() {
...@@ -347,11 +350,11 @@ public class FileLock { ...@@ -347,11 +350,11 @@ public class FileLock {
lockFile(); lockFile();
return; return;
} else if (!m2.equals(SOCKET)) { } else if (!m2.equals(SOCKET)) {
throw error("Unsupported lock method " + m2); throw getExceptionFatal("Unsupported lock method " + m2, null);
} }
String ip = p2.getProperty("ipAddress", ipAddress); String ip = p2.getProperty("ipAddress", ipAddress);
if (!ipAddress.equals(ip)) { if (!ipAddress.equals(ip)) {
throw error("Locked by another computer: " + ip); throw getExceptionAlreadyInUse("Locked by another computer: " + ip);
} }
String port = p2.getProperty("port", "0"); String port = p2.getProperty("port", "0");
int portId = Integer.parseInt(port); int portId = Integer.parseInt(port);
...@@ -359,27 +362,27 @@ public class FileLock { ...@@ -359,27 +362,27 @@ public class FileLock {
try { try {
address = InetAddress.getByName(ip); address = InetAddress.getByName(ip);
} catch (UnknownHostException e) { } catch (UnknownHostException e) {
throw getException(e); throw getExceptionFatal("Unknown host " + ip, e);
} }
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
try { try {
Socket s = new Socket(address, portId); Socket s = new Socket(address, portId);
s.close(); s.close();
throw error("Locked by another process"); throw getExceptionAlreadyInUse("Locked by another process");
} catch (BindException e) { } catch (BindException e) {
throw error("Bind Exception"); throw getExceptionFatal("Bind Exception", null);
} catch (ConnectException e) { } catch (ConnectException e) {
trace.debug("lockSocket not connected " + port, e); trace.debug("lockSocket not connected " + port, e);
} catch (IOException e) { } catch (IOException e) {
throw error("IOException"); throw getExceptionFatal("IOException", null);
} }
} }
if (read != fs.getLastModified(fileName)) { if (read != fs.getLastModified(fileName)) {
throw error("Concurrent update"); throw getExceptionFatal("Concurrent update", null);
} }
fs.delete(fileName); fs.delete(fileName);
if (!fs.createNewFile(fileName)) { if (!fs.createNewFile(fileName)) {
throw error("Another process was faster"); throw getExceptionFatal("Another process was faster", null);
} }
} }
try { try {
...@@ -418,15 +421,15 @@ public class FileLock { ...@@ -418,15 +421,15 @@ public class FileLock {
try { try {
Thread.sleep(time); Thread.sleep(time);
} catch (InterruptedException e) { } catch (InterruptedException e) {
throw getException(e); throw getExceptionFatal("Sleep interrupted", e);
} }
} }
private SQLException getException(Throwable t) { private SQLException getExceptionFatal(String reason, Throwable t) {
return Message.getSQLException(ErrorCode.ERROR_OPENING_DATABASE, null, t); return Message.getSQLException(ErrorCode.ERROR_OPENING_DATABASE_1, new String[]{reason}, t);
} }
private SQLException error(String reason) { private SQLException getExceptionAlreadyInUse(String reason) {
JdbcSQLException ex = Message.getSQLException(ErrorCode.DATABASE_ALREADY_OPEN_1, reason); JdbcSQLException ex = Message.getSQLException(ErrorCode.DATABASE_ALREADY_OPEN_1, reason);
String payload = null; String payload = null;
if (fileName != null) { if (fileName != null) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论