Skip to content

Conversation

@luoluoyuyu
Copy link
Member

Description

  • Change columnSchemaMap, tagColumnIndexMap, and idColumnIndexMap from final to volatile
  • Implement Copy-on-Write in executeWrite method:
    1. Create local copies of maps before modification
    2. Execute write operations on local copies
    3. Atomically update class fields after write completes
  • Add WriteOperation functional interface to pass map copies to write operations
  • This ensures readers see either complete old data or complete new data, avoiding ConcurrentModificationException

This PR has:

  • been self-reviewed.
    • concurrent read
    • concurrent write
    • concurrent read and write
  • added documentation for new or modified features or behaviors.
  • added Javadocs for most classes and all non-trivial methods.
  • added or updated version, license, or notice information
  • added comments explaining the "why" and the intent of the code wherever would not be obvious
    for an unfamiliar reader.
  • added unit tests or modified existing tests to cover new code paths, ensuring the threshold
    for code coverage.
  • added integration tests.
  • been tested in a test IoTDB cluster.

Key changed/added classes (or packages if there are too many classes) in this PR

…t access

- Change columnSchemaMap, tagColumnIndexMap, and idColumnIndexMap from final to volatile
- Implement Copy-on-Write in executeWrite method:
  1. Create local copies of maps before modification
  2. Execute write operations on local copies
  3. Atomically update class fields after write completes
- Add WriteOperation functional interface to pass map copies to write operations
- Add executeWriteWithTransform for efficient single-pass transformation during copy
- Optimize renameColumnSchema to preserve column order with single-pass copy
- This ensures readers see either complete old data or complete new data, avoiding ConcurrentModificationException
Comment on lines +170 to +173
// After write completes, atomically update the class fields
columnSchemaMap = newColumnSchemaMap;
tagColumnIndexMap = newTagColumnIndexMap;
idColumnIndexMap = newIdColumnIndexMap;
Copy link
Contributor

Choose a reason for hiding this comment

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

There may still introduce inconsistency

Copy link
Contributor

Choose a reason for hiding this comment

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

And, may only retain tagColumnIndexMap since id is a deprecated name

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.

2 participants