Windows에서 PostgreSQL을 C# 응용 프로그램으로 사용하고 있습니다. 내가 데 문제가 정말 이상한이며, 다음과 같이 설명 할 수 있습니다 Windows 재부팅 후 Postgresql이 특정 쿼리를 실패합니다.
- 나는 내 Windows는
- 내가 프로그램을 실행 다시 시작 은 하나 개의 특정 쿼리가 실패
- :
SELECT COUNT(*) AS c FROM files WHERE total_bytes IS NOT NULL
- 다시 프로그램을 실행
-
,536,913 : 모든 것이 정상적으로
이상한 노트 작동
- 그 전에 다른 쿼리를 만들려고했는데 같은 테이블을 사용해도 작동했습니다 :
SELECT COUNT(*) AS c FROM files
- Postgresql을 다시 시작하는 동안 오류를 재현하지 못했습니다. Windows 재부팅시에만 발생합니다. 그리고 그것은 단지 한 번 발생합니다.
예외 추적 : 나는이 프로그램 작업을 계속해야하기 때문에
Npgsql.NpgsqlException: Exception while reading from stream
at Npgsql.ReadBuffer.Ensure(Int32 count, Boolean dontBreakOnTimeouts)
at Npgsql.NpgsqlConnector.DoReadMessage(DataRowLoadingMode dataRowLoadingMode, Boolean isPrependedMessage)
at Npgsql.NpgsqlConnector.ReadMessageWithPrepended(DataRowLoadingMode dataRowLoadingMode)
at Npgsql.NpgsqlConnector.ReadMessage(DataRowLoadingMode dataRowLoadingMode)
at Npgsql.NpgsqlConnector.ReadExpecting[T]()
at Npgsql.NpgsqlDataReader.NextResultInternal()
at Npgsql.NpgsqlDataReader.NextResult()
at Npgsql.NpgsqlCommand.Execute(CommandBehavior behavior)
at Npgsql.NpgsqlCommand.ExecuteDbDataReaderInternal(CommandBehavior behavior)
at Npgsql.NpgsqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
at System.Data.Common.DbCommand.ExecuteReader()
at Npgsql.NpgsqlCommand.ExecuteReader()
at DriveShare.Database.Postgresql.ExecuteQuery(NpgsqlCommand command) in c:\projetos\driveshareclient\DriveShare\DriveShare\Database\Postgresql.cs:line 216
at DriveShare.Database.Postgresql.Query(String sql, Object[] args) in c:\projetos\driveshareclient\DriveShare\DriveShare\Database\Postgresql.cs:line 72
at DriveShare.Database.Postgresql.QueryOne(String sql, Object[] args) in c:\projetos\driveshareclient\DriveShare\DriveShare\Database\Postgresql.cs:line 83
at DriveShare.Database.Postgresql.QueryValue(String key, String sql, Object[] args) in c:\projetos\driveshareclient\DriveShare\DriveShare\Database\Postgresql.cs:line 97
at DriveShare.Database.Postgresql.QueryValue(String key, String sql) in c:\projetos\driveshareclient\DriveShare\DriveShare\Database\Postgresql.cs:line 92
at DriveShare.Database.FileIndexDataSet.CountIndexedFiles() in c:\projetos\driveshareclient\DriveShare\DriveShare\Database\FileIndexDataSet.cs:line 89
at DriveShare.Engine.DriveShareEngine.Start() in c:\projetos\driveshareclient\DriveShare\DriveShare\Engine\DriveShareEngine.cs:line 156
at DriveShareWebService.Program.Main(String[] args) in c:\projetos\driveshareclient\DriveShare\DriveShareWebService\Program.cs:line 19
, 나는 응용 프로그램이 진행하기 전에 해당 쿼리를 다시 시도 할 해결 방법을 썼다. 나는 자랑 아니에요 : 나는 PostgreSQL을에 연결 (얇은 추상화 클래스) Npgsql을 사용하고
public void WaitForConnection()
{
int limitSeconds = 3 * 60;
var start = DateTime.Now;
while (true)
{
try
{
Log.WaitingForDatabaseConnection();
Query("SELECT COUNT(*) AS c FROM files WHERE total_bytes IS NOT NULL");
Log.DatabaseConnectionAquired();
break;
}
catch (Exception e)
{
var wastedTime = DateTime.Now - start;
if (wastedTime.TotalSeconds > limitSeconds)
throw;
else
Log.Exception(e);
}
Thread.Sleep(1000);
}
}
.
2016-08-16 10:14:34 BRT LOG: database system was shut down at 2016-08-16 10:12:07 BRT
2016-08-16 10:14:34 BRT FATAL: the database system is starting up
2016-08-16 10:14:34 BRT LOG: MultiXact member wraparound protections are now enabled
2016-08-16 10:14:34 BRT LOG: sistema de banco de dados está pronto para aceitar conexões
2016-08-16 10:14:34 BRT LOG: autovacuum launcher started
2016-08-16 10:17:16 BRT LOG: could not receive data from client: unrecognized winsock error 10053
2016-08-16 10:17:27 BRT LOG: could not send data to client: unrecognized winsock error 10054
2016-08-16 10:17:27 BRT STATEMENT: SELECT path FROM files
2016-08-16 10:17:27 BRT FATAL: connection to client lost
2016-08-16 10:17:27 BRT STATEMENT: SELECT path FROM files
2016-08-16 10:17:27 BRT LOG: could not receive data from client: unrecognized winsock error 10053
2016-08-16 10:17:27 BRT LOG: unexpected EOF on client connection with an open transaction
2016-08-16 10:17:33 BRT LOG: unexpected EOF on client connection with an open transaction
2016-08-16 10:25:14 BRT LOG: could not receive data from client: unrecognized winsock error 10053
2016-08-16 10:25:15 BRT LOG: could not receive data from client: unrecognized winsock error 10053
2016-08-16 10:25:15 BRT LOG: unexpected EOF on client connection with an open transaction
2016-08-16 10:26:30 BRT LOG: could not send data to client: unrecognized winsock error 10054
2016-08-16 10:26:30 BRT FATAL: connection to client lost
2016-08-16 10:26:50 BRT LOG: could not send data to client: unrecognized winsock error 10054
2016-08-16 10:26:50 BRT FATAL: connection to client lost
2016-08-16 10:26:50 BRT LOG: could not receive data from client: unrecognized winsock error 10053
2016-08-16 10:26:50 BRT LOG: unexpected EOF on client connection with an open transaction
2016-08-16 10:27:06 BRT LOG: could not send data to client: unrecognized winsock error 10054
2016-08-16 10:27:06 BRT FATAL: connection to client lost
2016-08-16 10:27:06 BRT LOG: could not send data to client: unrecognized winsock error 10054
2016-08-16 10:27:06 BRT FATAL: connection to client lost
2016-08-16 10:27:30 BRT LOG: pedido de desligamento rápido foi recebido
2016-08-16 10:27:30 BRT LOG: interrompendo quaisquer transações ativas
2016-08-16 10:27:30 BRT LOG: autovacuum launcher shutting down
2016-08-16 10:27:30 BRT ERROR: canceling statement due to user request
2016-08-16 10:27:30 BRT LOG: autovacuum launcher shutting down
2016-08-16 10:27:30 BRT LOG: shutting down
2016-08-16 10:27:30 BRT LOG: database system is shut down
나는 누군가가 내 문제가 정확히 무엇인지 알고 기대하지 않는다 : PostgreSQL을 로그는 아직 이해하지 못하는 윈속 오류에 대한 일부 항목을 보여줍니다. 나는 누군가가 그것에 빛을 비출 수있는 비슷한 문제를 가지고 있었으면 좋겠다.
PgAdmin과 같은 다른 클라이언트를 사용하여 db를 쿼리하면 동일한 이상 동작이 발생합니까? 아니면 이상한 행동은 응용 프로그램에서만 발생합니까? – sstan
@sstan이 방금 테스트했습니다. 쿼리는 PgAdmin에서 작동했지만 처음 실행될 때 34 초 이상 걸렸습니다. 두 번째는 686ms. –
나는 그것이 윈도우 시작 혼란과 Npgsql에서 어떤 종류의 타임 아웃과 관련 될 수 있다고 생각하고있다. 이 쿼리는 트리거 할만큼 느려질 수 있습니다. –