What are the consequences of leaving the system without closing the tables?

Asked

Viewed 139 times

6

What are the consequences of Quit / Quit of a system without closing the database tables? This harms something in the database?

I should or should not close the system tables?

procedure TfrmTelaPrincipal.EncerraSistema;
begin
  Beep;
  if Application.MessageBox('Deseja Realmente Encerrar o Sistema?','Pergunta',
                        MB_YESNO+MB_ICONQUESTION+MB_DEFBUTTON2) <> IDNO then
  begin
    ReciclarLixoDeSistema;
    DMGeral.tbParametros.Edit;
    DMGeral.tbParametrosNUMERO_ESTACOES_LOGADAS.AsInteger := DMGeral.tbParametrosNUMERO_ESTACOES_LOGADAS.AsInteger-1;
    DMGeral.tbParametros.Post;
    MinimizarClick(Self);
    frmTelaPrincipal.Close;
  end;
end;

Ps: I use the structure client/server where the database is on the server and my connection component is Firedac

  • 2

    This question may have a thousand different answers. It depends a lot on the structure used (client > server > database or client > database), which components are used, which database and connection logic etc ...

  • It may actually have more than one consequence, I don’t have all, but one is it frees the session record in the database server memory, if there are too many connections and this isn’t thought out, it may burst the server ram memory.

  • I use the client/server structure where the database is on the server and my connection component is Firedac

2 answers

3

On the current system I am working on, end user license is done through transactional control between the application and the database Firebird.

That is, in this model, we know how many connections are active at the moment, so the application does not run if it exceeds the amount of transactions, it is a cheap and simple to make.

So in our case, transactional control is very important.

Each query we perform consists of an increase in the client process there on the server side, follows...

DataSetCliente := 'SELECT NOME, CPF, FROM CLIENTES WHERE CODIGO > 2500'

See that now the DataSetCliente is loaded with the selected data, however, we did not make a fetchall, whereas we have in this table 50,000 records the database does not immediately deliver the remaining 47,500 records, it will deliver only a portion of it.

In this case the client process of this transaction is on standby on the server side waiting to be requested more data, either through a Next or Last.

We then destroyed the DataSetCliente at the end of its use:

DataSetCliente.Close; //Aqui ele interrompe a transação, mas não a finaliza
DataSetCliente.Free; //Agora liberamos a transação

The importance depends on the connection model you are using, but as commented, it is very important for the Server side that this control exists.

Importantly, in this scenario, we are using Delphixe10.2 and the connecting component is from Devrace, Fibplus.

3

Does not corrupt the bank, but if any operation remains active, you can leave the locked, "locked" bank for other operations in the same table/record.

This type of behavior varies from one database to another, so it is a good practice to dislocate resources, close connections through resource protection structures like Try Finally

  • 2

    Depending on the type of connection not finalizing the table may result in continuity of the allocated memory, and it is possible to cause system crash by exceeding memory availability.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.