Skip to content

Conversation

@katzyn
Copy link
Contributor

@katzyn katzyn commented Jan 30, 2022

  1. Views and derived tables now have separate implementations based on the same common implementation.

  2. Immediate recompilation of derived table during initial parsing is removed.

  3. When derived table is recompiled in its index and index conditions are supported, but weren't applied its additional recompilation is removed. I think it shouldn't be performed in all cases, but without it some joins return wrong results. This needs further investigation.

  4. OOME with deeply nested derived tables is fixed. Closes OOME with nested derived tables #3410.

TimeUnit.MILLISECONDS.toNanos(Constants.VIEW_COST_CACHE_MAX_AGE);

private final TableView view;
private final QueryExpressionTable table;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HidingField: Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: Index (details)
(at-me in a reply with help or ignore)

// then we just compile it again.
TableView view;
synchronized (session) {
view = new TableView(schema, id, cteViewName, querySQL,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NULL_DEREFERENCE: object returned by getSchemaWithDefault() could be null and is dereferenced by call to TableView(...) at line 7494.
(at-me in a reply with help or ignore)


String sql = q.getPlanSQL(DEFAULT_SQL_FLAGS);
q = (Query) session.prepare(sql, true, true);
if (!sql.equals(querySQL)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NULL_DEREFERENCE: object sql last assigned on line 369 could be null and is dereferenced at line 370.
(at-me in a reply with help or ignore)

// for derived tables we don't need to use LRU because the cache
// should not grow too large for a single query (we drop the whole
// cache in this cache is dropped at the end of prepareLocal)
if (derivedTableIndexCache == null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

THREAD_SAFETY_VIOLATION: Read/Write race. Non-private method SessionLocal.getViewIndexCache(...) reads without synchronization from this.derivedTableIndexCache. Potentially races with write in method SessionLocal.prepareCommand(...).
Reporting because another access to the same memory occurs on a background thread, although this access may not.
(at-me in a reply with help or ignore)

// should not grow too large for a single query (we drop the whole
// cache in this cache is dropped at the end of prepareLocal)
if (derivedTableIndexCache == null) {
derivedTableIndexCache = new HashMap<>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

THREAD_SAFETY_VIOLATION: Unprotected write. Non-private method SessionLocal.getViewIndexCache(...) writes to field this.derivedTableIndexCache outside of synchronization.
Reporting because another access to the same memory occurs on a background thread, although this access may not.
(at-me in a reply with help or ignore)

@katzyn katzyn merged commit ec694e8 into h2database:master Feb 2, 2022
@katzyn katzyn deleted the oome branch February 2, 2022 04:01
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

Successfully merging this pull request may close these issues.

OOME with nested derived tables

1 participant