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

Live views aren't removed after disconnection (HTTP) #22996

Closed
loyd opened this issue Apr 12, 2021 · 9 comments
Closed

Live views aren't removed after disconnection (HTTP) #22996

loyd opened this issue Apr 12, 2021 · 9 comments
Labels
experimental feature Bug in the feature that should not be used in production

Comments

@loyd
Copy link
Contributor

loyd commented Apr 12, 2021

Description
If the WATCH statement is used via HTTP interface for live views with a timeout, the live view isn't removed after disconnection.

Steps to reproduce the bug

  1. Create a live view:
echo 'CREATE LIVE VIEW lv_http WITH TIMEOUT AS SELECT 1' | curl 'http://127.0.0.1:8123/?allow_experimental_live_view=1' --data-binary @-
  1. Watch it:
echo 'WATCH lv_http' | curl 'http://127.0.0.1:8123/?allow_experimental_live_view=1' --data-binary @-
1        1
  1. Send SIGINT.
  2. Check tables after at least 15s:
6c59ef6be4f2 :) SHOW TABLES;
┌─name────┐
│ lv_http │
└─────────┘

Which ClickHouse server version to use?
Checked 21.2.2.8.

Expected behavior
The live view should be removed after a timeout.

@loyd loyd added the bug Confirmed user-visible misbehaviour in official release label Apr 12, 2021
@alexey-milovidov alexey-milovidov added experimental feature Bug in the feature that should not be used in production and removed bug Confirmed user-visible misbehaviour in official release labels Apr 12, 2021
@vzakaznikov
Copy link
Contributor

This most likely means that the HTTP connection is not closed on the server and the live output stream never gets destroyed.

@vzakaznikov
Copy link
Contributor

@loyd, could you please try specifying JSONEachRowWithProgress as the output format? This will force the connection use heartbeats to keep HTTP connection alive. When client abruptly disappears it will force a fault on the next hearbeat and the output stream should close. So the max expected time for the table to be deleted will be heartbeat period + timeout period.

@loyd
Copy link
Contributor Author

loyd commented Apr 12, 2021

Yep, with JSONEachRowWithProgress it works as expected.

I write a library based on HTTP + RowBinary. I can switch to JSONEachRowWithProgress for WATCH, but it's not very convenient. Maybe I should shutdown the connection?

@loyd
Copy link
Contributor Author

loyd commented Apr 12, 2021

But emergencies are still possible, so the use of JSONEachRowWithProgress seems to be a more reliable method.

@vzakaznikov
Copy link
Contributor

But emergencies are still possible, so the use of JSONEachRowWithProgress seems to be a more reliable method.

Yes, you should only use JSONEachRowWithProgress format for WATCH queries over the HTTP connection. First, because HTTP connection needs heartbeat messages send periodically from the server to the client, and second, that's the only way the server can detect abruptly terminated client connections.

@vzakaznikov
Copy link
Contributor

@alexey-milovidov, we can close this issue as the behavior is not a bug in LIVE VIEW tables. The only potential issue is the inability of the ClickHouse server to detect dropped HTTP connections.

@loyd
Copy link
Contributor Author

loyd commented Nov 12, 2023

After #42173 it cannot be removed even with JSONEachRowWithProgress.

Should we reopen the issue or create a new one?

@vzakaznikov
Copy link
Contributor

vzakaznikov commented Nov 15, 2023

Hi @loyd, the WITH TIMEOUT has been removed and temporary LIVE VIEWs are not supported anymore.
That decision was made by the core team. I have not looked into if you can use TEMPORARY TABLEs instead. However, original WITH TIMEOUT live views were not session dependent and would be only automatically removed when there was no active WATCH queries.

#42173
#52333

@loyd
Copy link
Contributor Author

loyd commented Nov 25, 2023

@vzakaznikov, thx for the response. Do you know whether WINDOW VIEW can be used to emulate the semantic of LIVE VIEW?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
experimental feature Bug in the feature that should not be used in production
Projects
None yet
Development

No branches or pull requests

4 participants