fix timestamp calculation

This commit is contained in:
Vxider 2020-08-03 02:07:01 +08:00
parent 8868213104
commit fc8b5db486
3 changed files with 56 additions and 3 deletions

View File

@ -755,11 +755,9 @@ void StorageWindowView::threadFuncFireProc()
next_fire_signal = addTime(next_fire_signal, window_kind, window_num_units, *time_zone); next_fire_signal = addTime(next_fire_signal, window_kind, window_num_units, *time_zone);
} }
UInt64 timestamp_ms = static_cast<UInt64>(Poco::Timestamp().epochMicroseconds()); UInt64 timestamp_ms = static_cast<UInt64>(Poco::Timestamp().epochMicroseconds()) / 1000;
if (!shutdown_called) if (!shutdown_called)
{
fire_task->scheduleAfter(std::max(UInt64(0), static_cast<UInt64>(next_fire_signal) * 1000 - timestamp_ms)); fire_task->scheduleAfter(std::max(UInt64(0), static_cast<UInt64>(next_fire_signal) * 1000 - timestamp_ms));
}
} }
void StorageWindowView::threadFuncFireEvent() void StorageWindowView::threadFuncFireEvent()

View File

@ -0,0 +1,55 @@
#!/usr/bin/env python
import os
import sys
import signal
CURDIR = os.path.dirname(os.path.realpath(__file__))
sys.path.insert(0, os.path.join(CURDIR, 'helpers'))
from client import client, prompt, end_of_block
log = None
# uncomment the line below for debugging
# log=sys.stdout
with client(name='client1>', log=log) as client1, client(name='client2>', log=log) as client2:
client1.expect(prompt)
client2.expect(prompt)
client1.send('SET allow_experimental_window_view = 1')
client1.expect(prompt)
client1.send('SET window_view_heartbeat_interval = 1')
client1.expect(prompt)
client2.send('SET allow_experimental_window_view = 1')
client2.expect(prompt)
client1.send('DROP TABLE IF EXISTS test.mt')
client1.expect(prompt)
client1.send('DROP TABLE IF EXISTS test.wv')
client1.expect(prompt)
client1.send('DROP TABLE IF EXISTS `.inner.wv`')
client1.expect(prompt)
client1.send('CREATE TABLE test.mt(a Int32, timestamp DateTime) ENGINE=MergeTree ORDER BY tuple()')
client1.expect(prompt)
client1.send("CREATE WINDOW VIEW test.wv AS SELECT count(a) AS count FROM test.mt GROUP BY TUMBLE(timestamp, INTERVAL '1' SECOND) AS wid;")
client1.expect(prompt)
client1.send('WATCH test.wv')
client2.send('INSERT INTO test.mt VALUES (1, now())')
client1.expect('Progress: 0.00 rows.*\)')
client1.expect('1' + end_of_block)
client2.send('INSERT INTO test.mt VALUES (1, now())')
client1.expect('Progress: 0.00 rows.*\)')
client1.expect('1' + end_of_block)
# send Ctrl-C
client1.send('\x03', eol='')
match = client1.expect('(%s)|([#\$] )' % prompt)
if match.groups()[1]:
client1.send(client1.command)
client1.expect(prompt)
client1.send('DROP TABLE test.wv')
client1.expect(prompt)
client1.send('DROP TABLE test.mt')
client1.expect(prompt)