Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closing connection for database td.binlog #771

Closed
MalteToenjes opened this issue Nov 4, 2019 · 4 comments
Closed

Closing connection for database td.binlog #771

MalteToenjes opened this issue Nov 4, 2019 · 4 comments

Comments

@MalteToenjes
Copy link

Is there a way to close the database td.binlog on purpose?

When I call _self.td_json_client_destroy(self.td_json_client) (I'm using python-telegram), then I get this error:
[ 0][t 0][1572861952.897261381][Client.cpp:272] Check !is_locked failed

For the background:
In some cases I need to restart my API which uses tdlib. But since I can't close the database I cant free up the memory. So I think I have to close the connection to the database first. But I think the tdlib does create the connection, so there should be a way to tell the lib ti close the connection.

@levlam
Copy link
Contributor

levlam commented Nov 4, 2019

This is a sanity check that fires when app tries to destroy a client, which is still used in other thread by td_json_client_receive. You must first stop to use the client and only after that you can call td_json_client_destroy.

The usual way to do that is to call the method close, then wait for updateAuthoriationState with state authorizationStateClosed, stop calling td_json_client_receive and call td_json_client_destroy.

@MalteToenjes
Copy link
Author

I'm doing it now as you recommended but still get the same error. First I call the method close, then I wait for authorizationStateClosed and when its occured I call _td_json_client_destroy

[ 2][t 4][1572864873.717641830][Td.cpp:4184][#1][!Td] Close Td in state 2
[ 2][t 4][1572864873.717752218][Td.cpp:4038][#1][!Td] Have no request actors
[ 2][t 4][1572864873.718152285][Td.cpp:3959][#1][!Td] ON_ACTORS_CLOSED
{'@type': 'updateAuthorizationState', 'authorization_state': {'@type': 'authorizationStateClosing'}}}
[ 2][t 4][1572864873.769323111][Td.cpp:4016][#1][!Td] ON_CLOSED
{'@type': 'updateAuthorizationState', 'authorization_state': {'@type': 'authorizationStateClosed'}}
Calling _td_json_client_destroy...
[ 0][t 0][1572864873.769727468][Client.cpp:272] Check !is_locked failed

@levlam
Copy link
Contributor

levlam commented Nov 4, 2019

The error means that td_json_client_receive is called right now for the same client.

@MalteToenjes
Copy link
Author

Thanks, that was the problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants