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

Bump up calcite version and make upsert using materializedView threadsafe #103

Merged
merged 2 commits into from
Dec 13, 2023

Conversation

rbhanot
Copy link
Contributor

@rbhanot rbhanot commented Dec 13, 2023

  • Bump up plugin versions
  • Bump up calcite version
  • Bump up kudu version
  • Upserts would fail with exception -
Caused by: java.sql.SQLException: Error while preparing statement [UPSERT INTO "X" (.........) VALUES (..........)]

	at org.apache.calcite.avatica.Helper.createException(Helper.java:56)

	at org.apache.calcite.avatica.Helper.createException(Helper.java:41)

	at org.apache.calcite.jdbc.CalciteConnectionImpl.prepareStatement_(CalciteConnectionImpl.java:226)

	at org.apache.calcite.jdbc.CalciteConnectionImpl.prepareStatement(CalciteConnectionImpl.java:205)

	at org.apache.calcite.jdbc.KuduCalciteConnectionImpl.prepareStatement(KuduCalciteConnectionImpl.java:22)

	at org.apache.calcite.jdbc.CalciteConnectionImpl.prepareStatement(CalciteConnectionImpl.java:101)

	at org.apache.calcite.avatica.AvaticaConnection.prepareStatement(AvaticaConnection.java:178)

	at com.twilio.kudu.dataloader.DataLoader.lambda$loadData$2(DataLoader.java:327)

	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)

	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)

	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)

	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)

	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)

	at java.base/java.lang.Thread.run(Thread.java:833)

Caused by: java.util.ConcurrentModificationException

	at java.base/java.util.TreeMap.callMappingFunctionWithCheck(TreeMap.java:750)

	at java.base/java.util.TreeMap.computeIfAbsent(TreeMap.java:558)

	at org.apache.calcite.util.NameMultimap.put(NameMultimap.java:67)

	at org.apache.calcite.jdbc.CalciteSchema.add(CalciteSchema.java:216)

	at org.apache.calcite.jdbc.CalciteSchema.access$300(CalciteSchema.java:61)

	at org.apache.calcite.jdbc.CalciteSchema$SchemaPlusImpl.add(CalciteSchema.java:738)

	at com.twilio.kudu.sql.schema.KuduSchema.addMaterializedViews(KuduSchema.java:404)

	at com.twilio.kudu.sql.schema.KuduSchema.lambda$prepareAddMaterializationsHook$6(KuduSchema.java:415)

Making the above operation threadsafe to avoid error.

Contributing to Twilio

All third-party contributors acknowledge that any contributions they provide will be made under the same open-source license that the open-source project is provided under.

  • [ YES] I acknowledge that all my contributions will be made under the project's license.

@@ -397,12 +397,14 @@ private void addMaterializedViews() {
var entry = iterator.next();
// Add the view for this query
String viewName = "$" + getTableNames().size();
CalciteSchema calciteSchema = CalciteSchema.from(schema);
synchronized (schema) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nice catch, thanks for the fix.

@rbhanot rbhanot merged commit 826252f into twilio:main Dec 13, 2023
2 checks passed
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.

None yet

2 participants