| 1 |
/* |
| 2 |
* Licensed to the Apache Software Foundation (ASF) under one |
| 3 |
* or more contributor license agreements. See the NOTICE file |
| 4 |
* distributed with this work for additional information |
| 5 |
* regarding copyright ownership. The ASF licenses this file |
| 6 |
* to you under the Apache License, Version 2.0 (the |
| 7 |
* "License"); you may not use this file except in compliance |
| 8 |
* with the License. You may obtain a copy of the License at |
| 9 |
* |
| 10 |
* http://www.apache.org/licenses/LICENSE-2.0 |
| 11 |
* |
| 12 |
* Unless required by applicable law or agreed to in writing, |
| 13 |
* software distributed under the License is distributed on an |
| 14 |
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 |
* KIND, either express or implied. See the License for the |
| 16 |
* specific language governing permissions and limitations |
| 17 |
* under the License. |
| 18 |
*/ |
| 19 |
|
| 20 |
create table lock_workflows as |
| 21 |
select lock_held, file, timestamp as start_timestamp, "timestamp:1" as end_timestamp, thread, (lock_event || ' => ' || "lock_event:1") as lock_workflow, lock_mode, lock_name |
| 22 |
from ( |
| 23 |
select |
| 24 |
row_number() over ( |
| 25 |
partition by a.file, a.timestamp, a.thread, a.lock_event, a.lock_mode, a.lock_name |
| 26 |
order by r.timestamp asc |
| 27 |
) as rn, |
| 28 |
(r.timestamp - a.timestamp) as lock_held, a.*, r.* |
| 29 |
from lock_events a, lock_events r |
| 30 |
where r.file = a.file |
| 31 |
and r.thread = a.thread |
| 32 |
and r.timestamp >= a.timestamp |
| 33 |
and a.lock_event = 'acquire' and r.lock_event in ('release', 'acquire_failed') |
| 34 |
and a.lock_mode = r.lock_mode |
| 35 |
and a.lock_name = r.lock_name |
| 36 |
) |
| 37 |
where rn = 1 |
| 38 |
order by timestamp; |